Advertisement
Guest User

2x BasicVSR++

a guest
Mar 17th, 2023
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. core = vs.core
  5. import site
  6. import os
  7. import ctypes
  8. # Adding torch dependencies to PATH
  9. path = site.getsitepackages()[0]+'/torch_dependencies/bin/'
  10. ctypes.windll.kernel32.SetDllDirectoryW(path)
  11. path = path.replace('\\', '/')
  12. os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
  13. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  14. # Loading Plugins
  15. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  16. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  17. # source: 'G:\TestClips&Co\files\lossless\suzie_lossless..mp4'
  18. # current color space: YUV444P8, bit depth: 8, resolution: 176x144, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
  19. # Loading G:\TestClips&Co\files\lossless\suzie_lossless..mp4 using LibavSMASHSource
  20. clip = core.lsmas.LibavSMASHSource(source="G:/TestClips&Co/files/lossless/suzie_lossless..mp4")
  21. # Setting detected color matrix (470bg).
  22. clip = core.std.SetFrameProps(clip, _Matrix=5)
  23. # Setting color transfer info (470bg), when it is not set
  24. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
  25. # Setting color primaries info (), when it is not set
  26. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  27. # Setting color range to TV (limited) range.
  28. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  29. # making sure frame rate is set to 29.97
  30. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  31. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  32. # adjusting color space from YUV444P8 to RGBS for vsBasicVSRPP
  33. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  34. # Step 1: current: 176x144, target: 1056x796
  35. # resizing using BasicVSRPP
  36. from vsbasicvsrpp import BasicVSRPP
  37. # target zoom factor: 6 adjusted to 4
  38. clip = BasicVSRPP(clip=clip, model=2, fp16=True) # 704x576
  39. # resizing 704x576 to 1056x796
  40. # Step 2: current: 704x576, target: 1920x1436
  41. # resizing using BasicVSRPP
  42. # target zoom factor: 3 adjusted to 4
  43. clip = BasicVSRPP(clip=clip, model=2, fp16=True) # 2816x2304
  44. # resizing 2816x2304 to 1920x1436
  45. # adjusting resizing
  46. clip = core.fmtc.resample(clip=clip, w=1920, h=1436, kernel="lanczos", interlaced=False, interlacedd=False)
  47. # adjusting output color from: RGBS to YUV420P10 for x265Model
  48. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  49. # set output frame rate to 29.97fps (progressive)
  50. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  51. # Output
  52. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement