Guest User

Untitled

a guest
Nov 6th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import site
  5. import sys
  6. import os
  7. core = vs.core
  8. # Import scripts folder
  9. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  10. sys.path.insert(0, os.path.abspath(scriptPath))
  11. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  12. # loading plugins
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
  19. # Import scripts
  20. from importlib.machinery import SourceFileLoader
  21. vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
  22. import havsfunc
  23. import G41Fun
  24. import validate
  25. # Source: 'C:\Users\Selur\Desktop\c.avi'
  26. # Current color space: RGB24, bit depth: 8, resolution: 836x574, frame rate: 50fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, format: lagarith
  27. # Loading C:\Users\Selur\Desktop\c.avi using LWLibavSource
  28. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/c.avi", format="RGB24", stream_index=0, cache=0, fpsnum=50, prefer_hw=0)
  29. frame = clip.get_frame(0)
  30. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  31. if validate.transferIsInvalid(clip):
  32. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  33. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  34. if validate.primariesIsInvalid(clip):
  35. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  36. # making sure frame rate is set to 50fps
  37. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  38. # making sure the detected scan type is set (detected: progressive)
  39. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  40. # adjusting color space from RGB24 to YUV444P16 for vsFineSharp
  41. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
  42. # sharpening using FineSharp
  43. clip = G41Fun.FineSharp(clip=clip, mode=3)
  44. # applying dehalo using YAHR
  45. clip = havsfunc.YAHR(clip, depth=16)
  46. from vsmlrt import Backend
  47. clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=2) # add borders to archive mod 8 (vsDPIRmlrtDeblock) - 840x576
  48. # adjusting color space from YUV444P16 to RGBH for vsDPIRmlrtDeblock
  49. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
  50. # adjusting deblocking using DPIR (mlrt)
  51. 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"))
  52. clip = core.std.Crop(clip=clip, left=2, right=2, top=0, bottom=2) # removing borders (vsDPIRmlrtDeblock) - 836x574
  53. clipMerge = clip
  54. clipMerge = core.std.AddBorders(clip=clipMerge, left=2, right=2, top=0, bottom=2) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 840x576
  55. # Quality enhancement using BasicVSR++
  56. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  57. clipMerge = BasicVSRPP(clip=clipMerge, model=4)
  58. clipMerge = core.std.Crop(clip=clipMerge, left=2, right=2, top=0, bottom=2) # removing borders (vsBasicVSRPPFilter) - 836x574
  59. clipMerge = core.resize.Bicubic(clip=clipMerge, format=vs.YUV444P16, matrix_s="709", range_s="limited")
  60. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
  61. clip = core.std.Merge(clip,clipMerge,[0, 1, 1]) # merge filtered and unfiltered by plane
  62. clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=2) # add borders to archive mod 8 (vsSCUNetmlrt) - 840x576
  63. # changing range from limited to full range for vsSCUNetmlrt
  64. clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
  65. # setting color range to PC (full) range.
  66. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
  67. # adjusting color space from YUV444P16 to RGBH for vsSCUNetmlrt
  68. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="full")
  69. # denosing using SCUNet (mlrt)
  70. 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"))
  71. clip = core.std.Crop(clip=clip, left=2, right=2, top=0, bottom=2) # removing borders (vsSCUNetmlrt) - 836x574
  72. # changing range from full to limited range for vsSCUNetmlrt
  73. clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
  74. # adjusting output color from: RGBH to YUV444P10 for NVEncModel
  75. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
  76. # set output frame rate to 50fps (progressive)
  77. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  78. # output
  79. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment