Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import site
- import sys
- import os
- core = vs.core
- # Import scripts folder
- scriptPath = 'F:/Hybrid/64bit/vsscripts'
- sys.path.insert(0, os.path.abspath(scriptPath))
- os.environ["CUDA_MODULE_LOADING"] = "LAZY"
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
- # Import scripts
- from importlib.machinery import SourceFileLoader
- vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
- import havsfunc
- import G41Fun
- import validate
- # Source: 'C:\Users\Selur\Desktop\c.avi'
- # Current color space: RGB24, bit depth: 8, resolution: 836x574, frame rate: 50fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, format: lagarith
- # Loading C:\Users\Selur\Desktop\c.avi using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/c.avi", format="RGB24", stream_index=0, cache=0, fpsnum=50, prefer_hw=0)
- frame = clip.get_frame(0)
- # setting color transfer (vs.TRANSFER_BT601), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
- # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
- # making sure frame rate is set to 50fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
- # making sure the detected scan type is set (detected: progressive)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # adjusting color space from RGB24 to YUV444P16 for vsFineSharp
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
- # sharpening using FineSharp
- clip = G41Fun.FineSharp(clip=clip, mode=3)
- # applying dehalo using YAHR
- clip = havsfunc.YAHR(clip, depth=16)
- from vsmlrt import Backend
- clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=2) # add borders to archive mod 8 (vsDPIRmlrtDeblock) - 840x576
- # adjusting color space from YUV444P16 to RGBH for vsDPIRmlrtDeblock
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
- # adjusting deblocking using DPIR (mlrt)
- clip = vsmlrt.DPIR(clip, strength=50.000, overlap=16, model=3, backend=Backend.TRT(fp16=True, device_id=0,verbose=True,use_cuda_graph=False, num_streams=3,builder_optimization_level=3,engine_folder="J:/TRT"))
- clip = core.std.Crop(clip=clip, left=2, right=2, top=0, bottom=2) # removing borders (vsDPIRmlrtDeblock) - 836x574
- clipMerge = clip
- clipMerge = core.std.AddBorders(clip=clipMerge, left=2, right=2, top=0, bottom=2) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 840x576
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clipMerge = BasicVSRPP(clip=clipMerge, model=4)
- clipMerge = core.std.Crop(clip=clipMerge, left=2, right=2, top=0, bottom=2) # removing borders (vsBasicVSRPPFilter) - 836x574
- clipMerge = core.resize.Bicubic(clip=clipMerge, format=vs.YUV444P16, matrix_s="709", range_s="limited")
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
- clip = core.std.Merge(clip,clipMerge,[0, 1, 1]) # merge filtered and unfiltered by plane
- clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=2) # add borders to archive mod 8 (vsSCUNetmlrt) - 840x576
- # changing range from limited to full range for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
- # setting color range to PC (full) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
- # adjusting color space from YUV444P16 to RGBH for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="full")
- # denosing using SCUNet (mlrt)
- clip = vsmlrt.SCUNet(clip, model=4, overlap=16, backend=Backend.TRT(fp16=True,device_id=0,verbose=True,use_cuda_graph=False, num_streams=3,builder_optimization_level=3,engine_folder="J:/TRT"))
- clip = core.std.Crop(clip=clip, left=2, right=2, top=0, bottom=2) # removing borders (vsSCUNetmlrt) - 836x574
- # changing range from full to limited range for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
- # adjusting output color from: RGBH to YUV444P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
- # set output frame rate to 50fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
- # output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment