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.

Deoldify Vapoursynth filter
@Dan64: using:
# Imports
import sys
import os
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Limit frame cache to 48449MB
core.max_cache_size = 48449
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# loading plugins
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
# Import scripts
import vsdeoldify as havc
import validate
# Source: 'G:\TestClips&Co\files\test.avi'
# Current color space: YUV420P8, bit depth: 8, resolution: 640x352, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, format: MPEG-4 Visual
# Loading 'G:\TestClips&Co\files\test.avi' using BestSource
clip = core.bs.VideoSource(source="G:/TestClips&Co/files/test.avi", cachepath="J:/tmp/test_bestSource", track=0, hwdevice="opencl")
frame = clip.get_frame(0)
# setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
# 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)
# setting color range to TV (limited) range.
prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
# making sure frame rate is set to 25fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
original = clip
# changing color matrix from '470bg' to '709' for vsHAVC
clip = core.resize.Bicubic(clip, matrix_in_s="470bg", matrix_s="709")
# adjusting color space from YUV420P8 to RGB24 for vsHAVC
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_in_s="limited", range_s="full")
# adding colors using HAVC
clip = havc.HAVC_main(clip, EnableDeepEx=True, DeepExMethod=0, DeepExRefMerge=0, ScFrameDir=None, DeepExModel=0, DeepExEncMode=0, DeepExMaxMemFrames=0)
# internally changing color matrix for YUV<>RGB to '470bg' undoing color matrix change for vsHAVC
# adjusting output color from YUV420P8 to YUV420P10 for NVEncModel
original = core.resize.Bicubic(clip=original, format=vs.YUV420P10)
# adjusting output color from RGB24 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to match target color sampling
original = core.text.Text(clip=original,text="Original",scale=1,alignment=7)
clip = core.text.Text(clip=clip,text="Filtered",scale=1,alignment=7)
stacked = core.std.StackHorizontal([original,clip])
# set output frame rate to 25fps (progressive)
stacked = core.std.AssumeFPS(clip=stacked, fpsnum=25, fpsden=1)
# output
stacked.set_output()
the HAVC call is:
clip = havc.HAVC_main(clip, EnableDeepEx=True, DeepExMethod=0, DeepExRefMerge=0, ScFrameDir=None, DeepExModel=0, DeepExEncMode=0, DeepExMaxMemFrames=0)
I get:
2026-04-25 20:03:04.209
Failed to evaluate the script:
Python exception: CMNET2: number of reference frames must be at least 2, found 2

Traceback (most recent call last):
File "vapoursynth.pyx", line 3524, in vapoursynth._vpy_evaluate
File "vapoursynth.pyx", line 3525, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile20_01_43_472.vpy", line 44, in
clip = havc.HAVC_main(clip, EnableDeepEx=True, DeepExMethod=0, DeepExRefMerge=0, ScFrameDir=None, DeepExModel=0, DeepExEncMode=0, DeepExMaxMemFrames=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 321, in HAVC_main
return HAVC_main_presets(clip, Preset, FrameInterp, ColorModel, CombMethod, VideoTune, ColorFix,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 503, in HAVC_main_presets
clip_colored = HAVC_main_colorizer(clip, Preset, ColorModel, CombMethod, VideoTune, ColorFix, ColorTemp,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 840, in HAVC_main_colorizer
clip_colored = HAVC_deepex(clip=clip, clip_ref=clip_ref, method=DeepExMethod, render_speed=DeepExPreset,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 1728, in HAVC_deepex
clip_colored = vs_colormnet2(clip, clip_ref, clip_sc, image_size=-1, enable_resize=enable_resize,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\vsslib\vsmodels.py", line 70, in vs_colormnet2
return vs_colormnet2_remote(clip, clip_ref, clip_sc, image_size, enable_resize, frame_propagate,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\colormnet2\__init__.py", line 138, in vs_colormnet2_remote
clip_colored = _colormnet2_client(colorizer, clip, clip_ref, clip_sc, frame_propagate, ref_weight,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\colormnet2\__init__.py", line 155, in _colormnet2_client
reader.load_clip_ref(clip_ref, clip_sc, window_size=max_memory_frames)
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\colormnet2\colormnet2_utils.py", line 105, in load_clip_ref
self.get_clip_ref_list(sc, start_frame=start_frame, window_size=window_size)
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\colormnet2\colormnet2_utils.py", line 92, in get_clip_ref_list
HAVC_LogMessage(MessageType.EXCEPTION,
File "f:\hybrid\64bit\vapoursynth\Lib\site-packages\vsdeoldify\vsslib\vsutils.py", line 45, in HAVC_LogMessage
raise vs.Error(message_text)
vapoursynth.Error: CMNET2: number of reference frames must be at least 2, found 2

Cu Selur

Ps.: also uploaded a new Hybrid_havc_test
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
Please set ScMinFreq=15, I left some of defaults value of the previous release, CMNET2 need a stable source of reference frames and with the default value of threshold=0.10, it seems that was able to find only 2 reference frames.
I will update the RC.

Dan
Reply
But "number of reference frames must be at least 2, found 2" => shouldn't two be enough? Or did you mean that it need '3 or more' `?

Quote:Please set ScMinFreq=15, I left some of defaults value of the previous release,
Don't really get that sentence, but using 'ScMinFreq=15':
clip = havc.HAVC_main(clip, ColorFix="none", BlackWhiteTune="none", EnableDeepEx=True, DeepExMethod=0, DeepExPreset="medium", DeepExRefMerge=0, ScFrameDir=None, ScMinFreq=15, ScNormalize=True, DeepExModel=3, DeepExEncMode=0)
doesn't crash.

Let me know when defaults change, so that I can adjust the gui accordingly.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
Tomorrow I will release a new RC with the updated defaults.

Dan
Reply
Okay.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
When is selected the model CMNET2, must be available the same options available for ColorMNet: Mode (remote/local), Frames (number of memory frames).
The Mode="remote all-ref" has been removed in 5.8.0. It was my unsuccessful attempt to implement a sliding memory window.
This approach has been implemented in CMNET2 and thanks to the permanent memory of Xmem++, now is working very well. 

Dan
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)