This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Improving CodeFormer videos
#43
I tried to get your cuda dlib version working, but failed.
Here's what I did:
  • I copied 'dlib-19.24.1-cp311-cp311-win_amd64.whl' to 'Hybrid\64bit\Vapoursynth'
  • inside the Hybrid\64bit\Vapoursynth-folder I then called:
    python -m pip install dlib-19.24.1-cp311-cp311-win_amd64.whl
    which worked fine:
    Processing f:\hybrid\64bit\vapoursynth\dlib-19.24.1-cp311-cp311-win_amd64.whl
    Installing collected packages: dlib
    Successfully installed dlib-19.24.1
  • I then extracted the content of the vs-codeformer.zip into the 'Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer'-folder.
Trying:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Loading Plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
# Loading G:\TestClips&Co\files\test.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="G:/TestClips&Co/files/test.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
frame = clip.get_frame(0)
# Setting detected color matrix (470bg).
clip = core.std.SetFrameProps(clip, _Matrix=5)
# Setting color transfer (170), if it is not set.
if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  clip = core.std.SetFrameProps(clip, _Transfer=6)
# Setting color primaries info (to 470), if it is not set.
if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  clip = core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
# changing range from limited to full range
clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
# Setting color range to PC (full) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
# adjusting color space from YUV420P8 to RGB24 for vsCodeFormer
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="full")
# Blind Face Restoration using CodeFormer
from vscodeformer import codeformer as CodeFormer
clip = CodeFormer(clip=clip, upscale=1, detector=1, weight=1.000) # 640x352
# changing range from full to limited range
clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
# no resizing since resolution is already archived
# adjusting output color from: RGB24 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited")
# set output frame rate to 25fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
I got an exception:
Failed to evaluate the script:
Python exception: cannot access local variable 'dlib' where it is not associated with a value

Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 3115, in vapoursynth._vpy_evaluate
File "src\cython\vapoursynth.pyx", line 3116, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile17_04_54_105.vpy", line 34, in
clip = CodeFormer(clip=clip, upscale=1, detector=1, weight=1.000) # 640x352
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\__init__.py", line 102, in codeformer
face_helper = [
^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\__init__.py", line 103, in
FaceRestoreHelper(upscale, det_model=detection_model, use_parse=True, device=device) for _ in range(num_streams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\face_restoration_helper.py", line 113, in __init__
self.face_detector, self.shape_predictor_5 = self.init_dlib()
^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\face_restoration_helper.py", line 173, in init_dlib
face_detector = dlib.cnn_face_detection_model_v1(detection_path)
^^^^
UnboundLocalError: cannot access local variable 'dlib' where it is not associated with a value

replacing
if 'ON' == 'ON':
    add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cudnn.lib')
    add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cudart.lib')
with:
if 'ON' == 'ON':
    add_lib_to_dll_path('F:/Hybrid/64bit/Vapoursynth/torch_dependencies/cudnn.lib')
    add_lib_to_dll_path('F:/Hybrid/64bit/Vapoursynth/torch_dependencies/cudart.lib')
replacing these also does not change anything.

in Hybrid\64bit\Vapoursynth\Lib\site-packages\dlib\__init__.py didn't help.
(script works fine when dlib isn't used)

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Messages In This Thread
Improving CodeFormer videos - by Dan64 - 06.02.2024, 19:59
RE: Improving CodeFormer videos - by Selur - 06.02.2024, 20:08
RE: Improving CodeFormer videos - by Dan64 - 06.02.2024, 21:28
RE: Improving CodeFormer videos - by Selur - 07.02.2024, 15:37
RE: Improving CodeFormer videos - by Dan64 - 07.02.2024, 17:01
RE: Improving CodeFormer videos - by Selur - 07.02.2024, 17:04
RE: Improving CodeFormer videos - by Dan64 - 07.02.2024, 17:23
RE: Improving CodeFormer videos - by Selur - 07.02.2024, 17:48
RE: Improving CodeFormer videos - by Dan64 - 07.02.2024, 18:43
RE: Improving CodeFormer videos - by Selur - 07.02.2024, 19:43
RE: Improving CodeFormer videos - by Dan64 - 07.02.2024, 20:18
RE: Improving CodeFormer videos - by Selur - 07.02.2024, 20:20
RE: Improving CodeFormer videos - by Dan64 - 08.02.2024, 00:41
RE: Improving CodeFormer videos - by Selur - 08.02.2024, 05:47
RE: Improving CodeFormer videos - by Dan64 - 08.02.2024, 18:35
RE: Improving CodeFormer videos - by Selur - 08.02.2024, 19:09
RE: Improving CodeFormer videos - by Selur - 08.02.2024, 20:08
RE: Improving CodeFormer videos - by Dan64 - 09.02.2024, 19:04
RE: Improving CodeFormer videos - by Selur - 09.02.2024, 19:20
RE: Improving CodeFormer videos - by Selur - 09.02.2024, 19:44
RE: Improving CodeFormer videos - by Dan64 - 10.02.2024, 00:32
RE: Improving CodeFormer videos - by Dan64 - 10.02.2024, 11:27
RE: Improving CodeFormer videos - by Selur - 10.02.2024, 11:43
RE: Improving CodeFormer videos - by Dan64 - 10.02.2024, 19:21
RE: Improving CodeFormer videos - by Selur - 10.02.2024, 19:37
RE: Improving CodeFormer videos - by Dan64 - 10.02.2024, 20:02
RE: Improving CodeFormer videos - by Selur - 11.02.2024, 16:57
RE: Improving CodeFormer videos - by Dan64 - 12.02.2024, 22:11
RE: Improving CodeFormer videos - by Selur - 13.02.2024, 21:00
RE: Improving CodeFormer videos - by Dan64 - 13.02.2024, 21:51
RE: Improving CodeFormer videos - by Selur - 13.02.2024, 22:31
RE: Improving CodeFormer videos - by Dan64 - 13.02.2024, 23:53
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 01:05
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 06:40
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 09:26
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 09:37
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 09:40
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 09:42
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 10:19
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 10:22
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 10:24
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 16:40
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 18:52
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 21:32
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 21:37
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 21:37
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 21:38
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 21:40
RE: Improving CodeFormer videos - by Selur - 14.02.2024, 21:45
RE: Improving CodeFormer videos - by Dan64 - 14.02.2024, 21:48
RE: Improving CodeFormer videos - by Dan64 - 15.02.2024, 04:33
RE: Improving CodeFormer videos - by Selur - 15.02.2024, 06:28
RE: Improving CodeFormer videos - by Dan64 - 15.02.2024, 18:44
RE: Improving CodeFormer videos - by Selur - 15.02.2024, 19:02
RE: Improving CodeFormer videos - by Dan64 - 15.02.2024, 22:47
RE: Improving CodeFormer videos - by Selur - 16.02.2024, 05:33
RE: Improving CodeFormer videos - by Dan64 - 16.02.2024, 07:41
RE: Improving CodeFormer videos - by Dan64 - 16.02.2024, 19:01
RE: Improving CodeFormer videos - by Selur - 16.02.2024, 19:15
RE: Improving CodeFormer videos - by Selur - 16.02.2024, 19:31
RE: Improving CodeFormer videos - by Dan64 - 16.02.2024, 21:23
RE: Improving CodeFormer videos - by Selur - 16.02.2024, 21:42
RE: Improving CodeFormer videos - by Dan64 - 18.02.2024, 12:33
RE: Improving CodeFormer videos - by Selur - 18.02.2024, 13:05
RE: Improving CodeFormer videos - by Dan64 - 18.02.2024, 13:28
RE: Improving CodeFormer videos - by Selur - 18.02.2024, 13:38
RE: Improving CodeFormer videos - by Dan64 - 18.02.2024, 20:19
RE: Improving CodeFormer videos - by Selur - 18.02.2024, 20:23
RE: Improving CodeFormer videos - by Dan64 - 25.02.2024, 18:55
RE: Improving CodeFormer videos - by Selur - 25.02.2024, 19:12
RE: Improving CodeFormer videos - by Dan64 - 01.03.2024, 20:20
RE: Improving CodeFormer videos - by Selur - 01.03.2024, 20:24
RE: Improving CodeFormer videos - by Dan64 - 11.06.2024, 19:01
RE: Improving CodeFormer videos - by Selur - 11.06.2024, 19:02
RE: Improving CodeFormer videos - by Selur - 12.06.2024, 06:52

Forum Jump:


Users browsing this thread: 5 Guest(s)