Selur's Little Message Board

Full Version: SMDegrain KNLMeansCL prefilter error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Same for vsnlm_cuda / KNLMeansCL in VS - Misc - Tools

Code:
# Imports import sys import os import vapoursynth as vs # using Vapoursynth R79 # getting Vapoursynth core core = vs.core # Limit thread count to 12 core.num_threads = 12 # Limit frame cache to 8192MB core.max_cache_size = 8192 # Import scripts folder scriptPath = 'D:/APPD/Hybrid_dev_20260820-202122/64bit/vsscripts' sys.path.insert(0, os.path.abspath(scriptPath)) # loading plugins core.std.LoadPlugin(path="D:/APPD/Hybrid_dev_20260820-202122/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/vsnlm_ispc.dll") core.std.LoadPlugin(path="D:/APPD/Hybrid_dev_20260820-202122/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll") core.std.LoadPlugin(path="D:/APPD/Hybrid_dev_20260820-202122/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvutensils/mvutensils.dll") core.std.LoadPlugin(path="D:/APPD/Hybrid_dev_20260820-202122/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll") core.std.LoadPlugin(path="D:/APPD/Hybrid_dev_20260820-202122/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll") # Import scripts import nnedi3_resample import smdegrain import validate # Source: 'C:\Users\mmddffkk\Desktop\tmp\SAMPLE.mkv' # clip current meta; color space: YUV420P8, bit depth: 8, resolution: 1920x1080, fps: 23.976, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Source) # Loading 'C:\Users\mmddffkk\Desktop\tmp\SAMPLE.mkv' using LWLibavSource clip = core.lsmas.LWLibavSource(source="C:/Users/mmddffkk/Desktop/tmp/SAMPLE.mkv", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0) frame = clip.get_frame(0) # setting color matrix to 709. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709) # setting color transfer (vs.TRANSFER_BT709), if it is not set. if validate.transferIsInvalid(clip):   clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709) # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set. if validate.primariesIsInvalid(clip):   clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709) # 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 23.976fps clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001) # making sure the detected scan type is set (detected: progressive) clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive # removing grain using SMDegrain clip = smdegrain.SMDegrain(clip, interlaced=False, prefilter=4) # adjusting output color from YUV420P8 to YUV420P10 for SvtAv1Model clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, chromaloc=0) # set output frame rate to 23.976fps (progressive) clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001) # output clip.set_output() # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1920x1080, fps: 23.976, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta) # script was created by Hybrid 2026.08.20.1

Error Message
Code:
2026-08-21 17:33:31.970 Plugin D:/APPD/Hybrid_dev_20260820-202122/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/vsnlm_ispc.dll is using API3 which is deprecated and will be removed shortly. 2026-08-21 17:33:32.414 Failed to evaluate the script: Python exception: name 'KNLMeansCL' is not defined Traceback (most recent call last):   File "vapoursynth.pyx", line 3832, in vapoursynth._vpy_evaluate   File "vapoursynth.pyx", line 3833, in vapoursynth._vpy_evaluate   File "\\fx705d\enctmp\tempPreviewVapoursynthFile17_33_31_366.vpy", line 46, in <module>     clip = smdegrain.SMDegrain(clip, interlaced=False, prefilter=4)            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   File "D:\APPD\Hybrid_dev_20260820-202122\64bit\vsscripts\smdegrain.py", line 148, in SMDegrain     pref = KNLMeansCL(inputP, d=1, a=1, h=7)            ^^^^^^^^^^ NameError: name 'KNLMeansCL' is not defined
Ah,.. I forgot to adjust the prefilter calls to the KNLMeansCL selection. (need to adjust smdegrain.py)
=> looking into it
Uploaded a new dev with updated smdegrain.py and helpers.py which should fix it.
Note that even if you select nlm_cuda unless SMDegrain also has the OpenCL option enabled, Hybrid will fall back loading nlm_ispc.
But the script should work now in any case. Smile

Cu Selur
Yes, fixed in newest dev.  Smile