2
2
### 文档: https://github.com/hooke007/MPV_lazy/wiki/3_K7sfunc
3
3
##################################################
4
4
5
- __version__ = "0.4.3 "
5
+ __version__ = "0.4.6 "
6
6
7
7
__all__ = [
8
8
"FMT_CHANGE" , "FMT_CTRL" , "FPS_CHANGE" , "FPS_CTRL" ,
@@ -537,6 +537,12 @@ def CUGAN_NV(
537
537
if not hasattr (core , "trt" ) :
538
538
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 trt" )
539
539
540
+ plg_dir = os .path .dirname (core .trt .Version ()["path" ]).decode ()
541
+ mdl_fname = ["pro-no-denoise3x-up2x" , "pro-conservative-up2x" , "pro-denoise3x-up2x" ][[- 1 , 0 , 3 ].index (nr_lv )]
542
+ mdl_pth = plg_dir + "/models/cugan/" + mdl_fname + ".onnx"
543
+ if not os .path .exists (mdl_pth ) :
544
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
545
+
540
546
global vsmlrt
541
547
if vsmlrt is None :
542
548
try :
@@ -669,6 +675,12 @@ def ESRGAN_DML(
669
675
if not hasattr (core , "ort" ) :
670
676
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 ort" )
671
677
678
+ plg_dir = os .path .dirname (core .ort .Version ()["path" ]).decode ()
679
+ mdl_fname = ["RealESRGANv2-animevideo-xsx2" , "realesr-animevideov3" , "animejanaiV2L1" , "animejanaiV2L2" , "animejanaiV2L3" ][[0 , 2 , 5005 , 5006 , 5007 ].index (model )]
680
+ mdl_pth = plg_dir + "/models/RealESRGANv2/" + mdl_fname + ".onnx"
681
+ if not os .path .exists (mdl_pth ) :
682
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
683
+
672
684
global vsmlrt
673
685
if vsmlrt is None :
674
686
try :
@@ -730,6 +742,12 @@ def ESRGAN_NV(
730
742
if not hasattr (core , "trt" ) :
731
743
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 trt" )
732
744
745
+ plg_dir = os .path .dirname (core .trt .Version ()["path" ]).decode ()
746
+ mdl_fname = ["RealESRGANv2-animevideo-xsx2" , "realesr-animevideov3" , "animejanaiV2L1" , "animejanaiV2L2" , "animejanaiV2L3" ][[0 , 2 , 5005 , 5006 , 5007 ].index (model )]
747
+ mdl_pth = plg_dir + "/models/RealESRGANv2/" + mdl_fname + ".onnx"
748
+ if not os .path .exists (mdl_pth ) :
749
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
750
+
733
751
global vsmlrt
734
752
if vsmlrt is None :
735
753
try :
@@ -830,6 +848,13 @@ def WAIFU_DML(
830
848
if not hasattr (core , "ort" ) :
831
849
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 ort" )
832
850
851
+ plg_dir = os .path .dirname (core .ort .Version ()["path" ]).decode ()
852
+ mdl_pname = {3 :"upconv_7_anime_style_art_rgb/" , 5 :"upresnet10/" , 6 :"cunet/" }.get (model )
853
+ mdl_fname = ["scale2.0x_model" , "noise0_scale2.0x_model" , "noise1_scale2.0x_model" , "noise2_scale2.0x_model" , "noise3_scale2.0x_model" ][[- 1 , 0 , 1 , 2 , 3 ].index (nr_lv )]
854
+ mdl_pth = plg_dir + "/models/waifu2x/" + mdl_pname + mdl_fname + ".onnx"
855
+ if not os .path .exists (mdl_pth ) :
856
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
857
+
833
858
global vsmlrt
834
859
if vsmlrt is None :
835
860
try :
@@ -894,6 +919,13 @@ def WAIFU_NV(
894
919
if not hasattr (core , "trt" ) :
895
920
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 trt" )
896
921
922
+ plg_dir = os .path .dirname (core .trt .Version ()["path" ]).decode ()
923
+ mdl_pname = {3 :"upconv_7_anime_style_art_rgb/" , 5 :"upresnet10/" , 6 :"cunet/" }.get (model )
924
+ mdl_fname = ["scale2.0x_model" , "noise0_scale2.0x_model" , "noise1_scale2.0x_model" , "noise2_scale2.0x_model" , "noise3_scale2.0x_model" ][[- 1 , 0 , 1 , 2 , 3 ].index (nr_lv )]
925
+ mdl_pth = plg_dir + "/models/waifu2x/" + mdl_pname + mdl_fname + ".onnx"
926
+ if not os .path .exists (mdl_pth ) :
927
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
928
+
897
929
global vsmlrt
898
930
if vsmlrt is None :
899
931
try :
@@ -1032,8 +1064,8 @@ def _ffps(fps) :
1032
1064
1033
1065
cut1 = core .std .AssumeFPS (clip = cut0 , fpsnum = int (vfps ), fpsden = vden )
1034
1066
cut_s = core .mv .Super (clip = cut1 , sharp = 1 , rfilter = 4 )
1035
- cut_b = core .mv .Analyse (super = cut_s , blksize = 64 , searchparam = 0 , pelsearch = 3 , isb = True , _lambda = 0 , lsad = 10000 , overlapv = 16 , badrange = 0 , search_coarse = 4 )
1036
- cut_f = core .mv .Analyse (super = cut_s , blksize = 64 , searchparam = 0 , pelsearch = 3 , _lambda = 0 , lsad = 10000 , overlapv = 16 , badrange = 0 , search_coarse = 4 )
1067
+ cut_b = core .mv .Analyse (super = cut_s , blksize = 64 , searchparam = 0 , pelsearch = 3 , isb = True , lambda_ = 0 , lsad = 10000 , overlapv = 16 , badrange = 0 , search_coarse = 4 )
1068
+ cut_f = core .mv .Analyse (super = cut_s , blksize = 64 , searchparam = 0 , pelsearch = 3 , lambda_ = 0 , lsad = 10000 , overlapv = 16 , badrange = 0 , search_coarse = 4 )
1037
1069
1038
1070
output = core .mv .BlockFPS (clip = cut1 , super = cut_s , mvbw = cut_b , mvfw = cut_f , num = fps_out * 1000 , den = vden , mode = 2 , thscd1 = 970 , thscd2 = 255 , blend = False )
1039
1071
if w_tmp + h_tmp > 0 :
@@ -1185,7 +1217,7 @@ def RIFE_STD(
1185
1217
raise vs .Error (f"模块 { func_name } 的子参数 sc_mode 的值无效" )
1186
1218
if not isinstance (skip , bool ) :
1187
1219
raise vs .Error (f"模块 { func_name } 的子参数 skip 的值无效" )
1188
- if not isinstance (stat_th , (int , float )) or stat_th <= 0.0 :
1220
+ if not isinstance (stat_th , (int , float )) or stat_th <= 0.0 or stat_th > 60.0 :
1189
1221
raise vs .Error (f"模块 { func_name } 的子参数 stat_th 的值无效" )
1190
1222
if gpu not in [0 , 1 , 2 ] :
1191
1223
raise vs .Error (f"模块 { func_name } 的子参数 gpu 的值无效" )
@@ -1288,6 +1320,16 @@ def RIFE_NV(
1288
1320
if not hasattr (core , "akarin" ) :
1289
1321
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 akarin" )
1290
1322
1323
+ plg_dir = os .path .dirname (core .trt .Version ()["path" ]).decode ()
1324
+ mdl_pname = "rife/" if ext_proc else "rife_v2/"
1325
+ if t_tta :
1326
+ mdl_fname = ["rife_v4.6_ensemble" , "rife_v4.13_ensemble" , "rife_v4.13_lite_ensemble" ][[46 , 413 , 4131 ].index (model )]
1327
+ else :
1328
+ mdl_fname = ["rife_v4.6" , "rife_v4.13" , "rife_v4.13_lite" ][[46 , 413 , 4131 ].index (model )]
1329
+ mdl_pth = plg_dir + "/models/" + mdl_pname + mdl_fname + ".onnx"
1330
+ if not os .path .exists (mdl_pth ) :
1331
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
1332
+
1291
1333
global vsmlrt
1292
1334
if vsmlrt is None :
1293
1335
try :
@@ -1911,6 +1953,12 @@ def DPIR_NR_NV(
1911
1953
if not hasattr (core , "trt" ) :
1912
1954
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 trt" )
1913
1955
1956
+ plg_dir = os .path .dirname (core .trt .Version ()["path" ]).decode ()
1957
+ mdl_fname = ["drunet_gray" , "drunet_color" ][[0 , 1 ].index (model )]
1958
+ mdl_pth = plg_dir + "/models/dpir/" + mdl_fname + ".onnx"
1959
+ if not os .path .exists (mdl_pth ) :
1960
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
1961
+
1914
1962
global vsmlrt
1915
1963
if vsmlrt is None :
1916
1964
try :
@@ -2508,6 +2556,12 @@ def DPIR_DBLK_NV(
2508
2556
if not hasattr (core , "trt" ) :
2509
2557
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 trt" )
2510
2558
2559
+ plg_dir = os .path .dirname (core .trt .Version ()["path" ]).decode ()
2560
+ mdl_fname = ["drunet_deblocking_grayscale" , "drunet_deblocking_color" ][[2 , 3 ].index (model )]
2561
+ mdl_pth = plg_dir + "/models/dpir/" + mdl_fname + ".onnx"
2562
+ if not os .path .exists (mdl_pth ) :
2563
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
2564
+
2511
2565
global vsmlrt
2512
2566
if vsmlrt is None :
2513
2567
try :
@@ -2801,7 +2855,7 @@ def UAI_DML(
2801
2855
raise vs .Error (f"模块 { func_name } 的子参数 input 的值无效" )
2802
2856
if not isinstance (clamp , bool ) :
2803
2857
raise vs .Error (f"模块 { func_name } 的子参数 clamp 的值无效" )
2804
- if len (model_pth ) == 0 :
2858
+ if len (model_pth ) <= 5 :
2805
2859
raise vs .Error (f"模块 { func_name } 的子参数 model_pth 的值无效" )
2806
2860
if gpu not in [0 , 1 , 2 ] :
2807
2861
raise vs .Error (f"模块 { func_name } 的子参数 gpu 的值无效" )
@@ -2816,6 +2870,11 @@ def UAI_DML(
2816
2870
if not hasattr (core , "akarin" ) :
2817
2871
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 akarin" )
2818
2872
2873
+ mdl_pth_rel = os .path .join (vsmlrt .models_path , model_pth )
2874
+ if not os .path .exists (mdl_pth_rel ) and not os .path .exists (model_pth ) :
2875
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
2876
+ mdl_pth = mdl_pth_rel if os .path .exists (mdl_pth_rel ) else model_pth
2877
+
2819
2878
global vsmlrt
2820
2879
if vsmlrt is None :
2821
2880
try :
@@ -2833,7 +2892,7 @@ def UAI_DML(
2833
2892
if clamp :
2834
2893
clip = core .akarin .Expr (clips = clip , expr = "x 0 1 clamp" )
2835
2894
be_param = vsmlrt .BackendV2 .ORT_DML (device_id = gpu , num_streams = gpu_t , fp16 = True )
2836
- infer = vsmlrt .inference (clips = clip , network_path = os . path . join ( vsmlrt . models_path , model_pth ) , backend = be_param )
2895
+ infer = vsmlrt .inference (clips = clip , network_path = mdl_pth , backend = be_param )
2837
2896
output = core .resize .Bilinear (clip = infer , format = fmt_in , matrix_s = "709" , range = 1 if colorlv == 0 else None )
2838
2897
2839
2898
return output
@@ -2863,7 +2922,7 @@ def UAI_NV_TRT(
2863
2922
raise vs .Error (f"模块 { func_name } 的子参数 input 的值无效" )
2864
2923
if not isinstance (clamp , bool ) :
2865
2924
raise vs .Error (f"模块 { func_name } 的子参数 clamp 的值无效" )
2866
- if len (model_pth ) == 0 :
2925
+ if len (model_pth ) <= 5 :
2867
2926
raise vs .Error (f"模块 { func_name } 的子参数 model_pth 的值无效" )
2868
2927
if opt_lv not in [0 , 1 , 2 , 3 , 4 , 5 ] :
2869
2928
raise vs .Error (f"模块 { func_name } 的子参数 opt_lv 的值无效" )
@@ -2896,6 +2955,11 @@ def UAI_NV_TRT(
2896
2955
if not hasattr (core , "akarin" ) :
2897
2956
raise ModuleNotFoundError (f"模块 { func_name } 依赖错误:缺失插件,检查项目 akarin" )
2898
2957
2958
+ mdl_pth_rel = os .path .join (vsmlrt .models_path , model_pth )
2959
+ if not os .path .exists (mdl_pth_rel ) and not os .path .exists (model_pth ) :
2960
+ raise vs .Error (f"模块 { func_name } 所请求的模型缺失" )
2961
+ mdl_pth = mdl_pth_rel if os .path .exists (mdl_pth_rel ) else model_pth
2962
+
2899
2963
global vsmlrt
2900
2964
if vsmlrt is None :
2901
2965
try :
@@ -2918,7 +2982,7 @@ def UAI_NV_TRT(
2918
2982
num_streams = gpu_t , use_cuda_graph = nv1 , use_cublas = nv2 , use_cudnn = nv3 ,
2919
2983
fp16 = fp16 , force_fp16 = False , tf32 = True , output_format = 1 if fp16 else 0 , workspace = None if ws_size < 128 else (ws_size if st_eng else ws_size * 2 ),
2920
2984
static_shape = st_eng , min_shapes = [0 , 0 ] if st_eng else [64 , 64 ], opt_shapes = None if st_eng else res_opt , max_shapes = None if st_eng else res_max )
2921
- infer = vsmlrt .inference (clips = clip , network_path = os . path . join ( vsmlrt . models_path , model_pth ) , backend = be_param )
2985
+ infer = vsmlrt .inference (clips = clip , network_path = mdl_pth , backend = be_param )
2922
2986
output = core .resize .Bilinear (clip = infer , format = fmt_in , matrix_s = "709" , range = 1 if colorlv == 0 else None )
2923
2987
2924
2988
return output
0 commit comments