求助最新版的havsfunc使用
更新了,貌似很多参数用不了例如报错
import havsfunc as haf
File "J:\vapoursynth_portable_24H1p_cpu+cuda.7z\vapoursynth\VapourSynthScripts\havsfunc.py", line 8, in
from vsdenoise import BM3D, nl_means, prefilter_to_full_range
ModuleNotFoundError: No module named 'vsdenoise'
然后查看了py文件里面的说明
def HQDeringmod(*args, **kwargs):
raise vs.Error(
"havsfunc.HQDeringmod outdated. Use 链接 instead."
譬如我想使用去ring的滤镜,说这个HQDeringmod已经移除了,使用vs-dehalo替代,问题来了,
跑去啃文档,发觉也不会用啊,求支招,该怎样调用,是import 里面的XXX.py文件,然后vs脚本那直接调用函数吗,不过试过也报错
Jaded Encoding Thaumaturgy 那个里面的 vs 脚本几乎都没有文档,只能读源码
比如 vs-dehalo 的 readme 里写了 dehaloed = fine_dehalo(src)
用 vscode 打开源码搜 fine_dehalo 读就完事了(
例如 __init__.py 里 import 了 *,alpha.py 里
__all__ = [
'fine_dehalo',
'fine_dehalo2',
'dehalo_alpha',
'dehalo_sigma',
'dehalomicron',
'dehalo_merge'
]
fine_dehalo = _fine_dehalo()
所以 readme 里的 fine_dehalo 就是一个对象,看 class 定义里的 __call__ 就是用来初始化的(它返回了一个VideoNode对象)
__call__ 下面那一大坨注释就是用法了
虽然这坨注释也就写这个代码的人能看懂( 本帖最后由 nyaru 于 2025-1-5 16:44 编辑
你可以使用旧版
def HQDeringmod2(input, p=None, ringmask=None, mrad=1, msmooth=1, incedge=False, mthr=60, minp=1, nrmode=None, sharp=1, drrep=24, thr=12.0, elast=2.0, darkthr=None, planes=, show=False):
if not isinstance(input, vs.VideoNode):
raise vs.Error('HQDeringmod: this is not a clip')
if input.format.color_family == vs.RGB:
raise vs.Error('HQDeringmod: RGB format is not supported')
if p is not None and (not isinstance(p, vs.VideoNode) or p.format.id != input.format.id):
raise vs.Error("HQDeringmod: 'p' must have the same format as input")
if ringmask is not None and not isinstance(ringmask, vs.VideoNode):
raise vs.Error("HQDeringmod: 'ringmask' is not a clip")
import math
def cround(x):
return math.floor(x + 0.5) if x > 0 else math.ceil(x - 0.5)
def drscale(value, peak):
return cround(value * peak / 255) if peak != 1 else value / 255
isGray = (input.format.color_family == vs.GRAY)
neutral = 1 << (input.format.bits_per_sample - 1)
peak = (1 << input.format.bits_per_sample) - 1
if isinstance(planes, int):
planes =
if nrmode is None:
nrmode = 2 if input.width > 1024 or input.height > 576 else 1
if darkthr is None:
darkthr = thr / 4
# Kernel: Smoothing
if p is None:
p = MinBlur(input, r=nrmode, planes=planes)
# Post-Process: Contra-Sharpening
matrix1 =
matrix2 =
if sharp <= 0:
sclp = p
else:
pre = p.std.Median(planes=planes)
if sharp == 1:
method = pre.std.Convolution(matrix=matrix1, planes=planes)
elif sharp == 2:
method = pre.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
else:
method = pre.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
sharpdiff = core.std.MakeDiff(pre, method, planes=planes)
allD = core.std.MakeDiff(input, p, planes=planes)
ssDD = core.rgvs.Repair(sharpdiff, allD, mode=)
expr = f'x {neutral} - abs y {neutral} - abs <= x y ?'
ssDD = core.std.Expr(, expr=)
sclp = core.std.MergeDiff(p, ssDD, planes=planes)
# Post-Process: Repairing
if drrep <= 0:
repclp = sclp
else:
repclp = core.rgvs.Repair(input, sclp, mode=)
# Post-Process: Limiting
if (thr <= 0 and darkthr <= 0) or (thr >= 128 and darkthr >= 128):
limitclp = repclp
else:
limitclp = mvf.LimitFilter(repclp, input, thr=thr, elast=elast, brighten_thr=darkthr, planes=planes)
# Post-Process: Ringing Mask Generating
if ringmask is None:
expr = f'x {drscale(mthr, peak)} < 0 x ?'
prewittm = AvsPrewitt(input, planes=).std.Expr(expr= if isGray else )
fmask = core.misc.Hysteresis(prewittm.std.Median(planes=), prewittm, planes=)
if mrad > 0:
omask = mt_expand_multi(fmask, planes=, sw=mrad, sh=mrad)
else:
omask = fmask
if msmooth > 0:
omask = mt_inflate_multi(omask, planes=, radius=msmooth)
if incedge:
ringmask = omask
else:
if minp > 3:
imask = fmask.std.Minimum(planes=).std.Minimum(planes=)
elif minp > 2:
imask = fmask.std.Inflate(planes=).std.Minimum(planes=).std.Minimum(planes=)
elif minp > 1:
imask = fmask.std.Minimum(planes=)
elif minp > 0:
imask = fmask.std.Inflate(planes=).std.Minimum(planes=)
else:
imask = fmask
expr = f'x {peak} y - * {peak} /'
ringmask = core.std.Expr(, expr= if isGray else )
# Mask Merging & Output
if show:
if isGray:
return ringmask
else:
return ringmask.std.Expr(expr=['', repr(neutral)])
else:
return core.std.MaskedMerge(input, limitclp, ringmask, planes=planes, first_plane=True)
def MinBlur(clp, r=1, planes=None):
if not isinstance(clp, vs.VideoNode):
raise vs.Error('MinBlur: this is not a clip')
if planes is None:
planes = list(range(clp.format.num_planes))
elif isinstance(planes, int):
planes =
matrix1 =
matrix2 =
if r <= 0:
RG11 = sbr(clp, planes=planes)
RG4 = clp.std.Median(planes=planes)
elif r == 1:
RG11 = clp.std.Convolution(matrix=matrix1, planes=planes)
RG4 = clp.std.Median(planes=planes)
elif r == 2:
RG11 = clp.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
RG4 = clp.ctmf.CTMF(radius=2, planes=planes)
else:
RG11 = clp.std.Convolution(matrix=matrix1, planes=planes).std.Convolution(matrix=matrix2, planes=planes).std.Convolution(matrix=matrix2, planes=planes)
if clp.format.bits_per_sample == 16:
s16 = clp
RG4 = clp.fmtc.bitdepth(bits=12, planes=planes, dmode=1).ctmf.CTMF(radius=3, planes=planes).fmtc.bitdepth(bits=16, planes=planes)
RG4 = mvf.LimitFilter(s16, RG4, thr=0.0625, elast=2, planes=planes)
else:
RG4 = clp.ctmf.CTMF(radius=3, planes=planes)
expr = 'x y - x z - * 0 < x x y - abs x z - abs < y z ? ?'
return core.std.Expr(, expr=)
def AvsPrewitt(clip, planes=None):
if not isinstance(clip, vs.VideoNode):
raise vs.Error('AvsPrewitt: this is not a clip')
if planes is None:
planes = list(range(clip.format.num_planes))
elif isinstance(planes, int):
planes =
return core.std.Expr(, planes=planes, saturate=False),
clip.std.Convolution(matrix=, planes=planes, saturate=False),
clip.std.Convolution(matrix=, planes=planes, saturate=False),
clip.std.Convolution(matrix=, planes=planes, saturate=False)],
expr=['x y max z max a max' if i in planes else '' for i in range(clip.format.num_planes)])
def mt_inflate_multi(src, planes=None, radius=1):
if not isinstance(src, vs.VideoNode):
raise vs.Error('mt_inflate_multi: this is not a clip')
for i in range(radius):
src = core.std.Inflate(src, planes=planes)
return src nyaru 发表于 2025-1-5 16:38
你可以使用旧版
好的,只能自己封一个调用了
新的那个我是真的看不明白,主要老报错,但是又不知道错在哪,感觉对于新人不是很友好
op200 发表于 2025-1-5 16:20
Jaded Encoding Thaumaturgy 那个里面的 vs 脚本几乎都没有文档,只能读源码
比如 vs-dehalo 的 readme 里 ...
谢谢回复,我试试
我用的 commit 时间点:https://gist.github.com/RyougiKukoc/ea451bd51d0dc33ba5e0c4d5566653cf
页:
[1]