Selur's Little Message Board

Full Version: Deoldify Vapoursynth filter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The new RC3 removed and added some file, maybe is better to replace completely the vs-deoldify folder with the new RC3 (keep the models stuff like *.pth and related files).
The error on colorizer it is normal at the first run because of order on witch are compiled the python scripts.
If you run again the second time should work. 

In the attachment are provided 2 sample script, that you can use to test the method=5 in RC3.

HAVC_main_method5.vpy  with the call to HAVC_main

Code:
sc_framedir="test_green_color.mp4"
clip = havc.HAVC_main(clip=clip, Preset="fast", ColorModel="Video+Artistic", VideoTune="balanced", ColorFix="violet/red", ColorTune="light", ColorMap="red->brown", BlackWhiteTune="none", EnableDeepEx=True, DeepExMethod=havc.HAVC_RESTORE_VIDEO, DeepExPreset="medium", DeepExRefMerge=0, DeepExOnlyRefFrames=False, ScFrameDir=sc_framedir, ScThreshold=0.10, ScThtOffset=1, ScMinFreq=10, ScMinInt=1, ScThtSSIM=0.00, ScNormalize=False, DeepExModel=havc.DeepRemaster, DeepExEncMode=0, DeepExVivid=True, DeepExMaxMemFrames=10)

HAVC_custom_method5.vpy with the call to custom functions

Code:
clip_ref = havc.HAVC_read_video(source="test_green_color.mp4", fpsnum=24000, fpsden=1001)
clip=havc.HAVC_restore_video(clip, clip_ref, render_speed="medium", ex_model=havc.DeepRemaster, ref_merge=0, ref_thresh=0.10, ref_freq=10, max_memory_frames=10, render_vivid=True)

In the previous version released for test, all was working (including the custom section) with the only exception of method=5.

So I concentrate the explanations only on the management of method=5.

I'm not asking to rewrite all the HAVC Hybrid code. Just to add the management of method=5.

This imply few steps:

1) read from the GUI the path to clip to restore
2) call the HAVC functions as shown in
      
        HAVC_main_method5.vpy when is used the Speed != "custom"
        HAVC_custom_method5.vpy when is used the Speed == "custom"

I don't want to complicate the implementation more than necessary. Smile 

Thanks,
Dan

P.S.
please re-enable the "custom" section
Quote:please re-enable the "custom" section
Not until the non-custom section is working completely.

Quote:DeepExMethod=havc.HAVC_RESTORE_VIDEO
Where did that come from? I thought DeepExMethod was an integer?
Code:
:param DeepExMethod:        Method to use to generate reference frames.
                                        0 = HAVC same as video (default)
                                        1 = HAVC + RF same as video
                                        2 = HAVC + RF different from video
                                        3 = external RF same as video
                                        4 = external RF different from video
                                        5 = HAVC video restore
ahh,.. you defined some constants,...

Quote: The new RC3 removed and added some file, maybe is better to replace completely the vs-deoldify folder with the new RC3 (keep the models stuff like *.pth and related files).
Angry Angry Angry Angry Angry Angry Angry Angry

I'll look at it over the weekend.

Cu Selur
Respect to version 4.6.8 the version 5.0.0 RC3

Added:

havc_constants.py
havc_filters.py
havc_utils.py

Removed

vsslib\constants.py

in the function havc_constants.py I added some constants to identify the models and to assign defaults values.

The constants related to Parameter Values are:

Code:
HAVC_SAME_AS_VIDEO=0
HAVC_RF_SAME_AS_VIDEO=1
HAVC_RF_DIFF_VIDEO=2
EXTERNAL_RF_AS_VIDEO=3
EXTERNAL_RF_DIFF_VIDEO=4
HAVC_RESTORE_VIDEO=5
ColorMNet=0
DeepExemplar=1
DeepRemaster=2

I'm planning to add the identifiers for the other models: deoldify, ddcolor, Zhang...

If at the beginning of the script you add the following code

Code:
import vsdeoldify as havc

you can use these constants inside the script.

Dan
Quote:you can use these constants inside the script.
I know, maybe I'll do that at some point, atm. I don't want to add another change.
First, the existing stuff needs to work.
Then I can look into things one at a time.
Atm. I spend an hour coding, just to see that you changed stuff and I can start rewriting again since there are changes everywhere.
Your RCs are basically alphas, normally RC implies a feature&interface freeze.
After a RC, there should only be bug fixes, no new features an interface changes.

=> until non-custom HAVC works, 'custom' stays removed.
Then I look at method 0, 1, 2, 4, 5, if the interface&co until custom works complete, custom gets disabled and I go back to first testing non-custom.

Cu Selur
Dear Selur, Please continue to support DeepRemaster. Your work on HAVC is already remarkable, and what you're doing with it is truly impressive. Thank you for your dedication and for moving things forward with such precision. A big thank you also to Dan for all his efforts and incredible ideas with HAVC! Yours sincerely
Sometime I forgot that python is not a true language.

I spent 3 hours to understand that ColorMNet was broken because I called a constant ColorMNet and python was calling the constant instead to call the function, obviously without issue any message that made sense. Also the debugger was unable to recognize that was called a constant instead of a function. It simple refuse to step-in, even in this case without issue any message that made sense.

Attached the new RC4.

Removed:

havc_constants.py
havc_filters.py

Added:

havc_utils.py
vsslib\constants.py

Removed all the parameters constants.

Included new sample test, with the parameters constants removed.  

Sorry for the inconvenience, I had to rollback a lot of code before find the reason of ColorMNet failure.

Dan
With that version non-custom seems to work.
'custom' does not work for me on my first test:
Code:
# adjusting color space from YUV420P8 to RGB24 for vsDeOldify
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full")
# adding colors using DeOldify
clipRef = HAVC_read_video(source="G:/TestClips&Co/files/test_ref.avi")
clip = HAVC_restore_video(clip=clip, clip_ref=clipRef, ex_model=2, ref_merge=0, max_memory_frames=0)
# internally changing color matrix for YUV<>RGB to '470bg' undoing color matrix change for vsDeOldify
# changing range from full to limited range for vsDeOldify
clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
Seems like HAVC_read_video doesn't work.
Code:
Failed to evaluate the script:
Python exception: SetFrameProp: one of 'intval', 'floatval', or 'data' must be passed->

Traceback (most recent call last):
File "src\\cython\\vapoursynth.pyx", line 3387, in vapoursynth._vpy_evaluate
File "src\\cython\\vapoursynth.pyx", line 3388, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile14_38_37_430.vpy", line 48, in
clip = HAVC_restore_video(clip=clip, clip_ref=clipRef, ex_model=2, ref_merge=0, max_memory_frames=0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsdeoldify\__init__.py", line 831, in HAVC_restore_video
clip_ref = SceneDetect(clip_ref, threshold=ref_thresh, frequency=ref_freq)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsdeoldify\vsslib\vsscdect.py", line 46, in SceneDetect
clip = clip.std.SetFrameProp(prop="sc_threshold", floatval=threshold)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src\\cython\\vapoursynth.pyx", line 3123, in vapoursynth.Function.__call__
vapoursynth.Error: SetFrameProp: one of 'intval', 'floatval', or 'data' must be passed->
No clue whether Hybrid isn't setting something wrong or missed to set something or whether it's a bug in your code.

Updated Hybrid_deoldify. (did not write code when FilterQueue is used, so this is limited to FilterOrder)

Cu Selur
When Hybrid call HAVC_read_video must provide also the parameters fpsnum, fpsden

My example was not perfect, the exact way to call HAVC_read_video is

Code:
clip_ref = HAVC_read_video(source=ScFrameDir, fpsnum=clip.fps_num, fpsden=clip.fps_den)

 the clip_ref can have different frame size or number of frames, but must have the same fps of clip to be colored, so it is necessary to pass  clip.fps_num,  fpsden=clip.fps_den 

Thanks,
Dan

(07.02.2025, 17:47)Selur Wrote: [ -> ]https://github.com/HolyWu/vs-rife/commit...063beae292
=> unbelievable  Cool

HolyWu is deeply involved in the development of torch. 
I think that he is using his projects to test and develop new features for torch.
Unfortunately torch is not stable and is still under strong development. Sad

Dan