Last active
July 14, 2023 01:05
-
-
Save hooke007/ce3e04b549f48103d15dfe3e21c364b0 to your computer and use it in GitHub Desktop.
[mpv-filter_vapoursynth] 图像放大
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### waifu2x算法放大两倍 | |
### 依赖: https://github.com/nlzy/vapoursynth-waifu2x-ncnn-vulkan/releases/tag/r5 (模型文件在r0.1) | |
import vapoursynth as vs | |
from vapoursynth import core | |
input = video_in | |
colorlv = input.get_frame(0).props._ColorRange | |
fmt_fin = input.format.id | |
denoise_lv = 1 | |
scale_model = 1 | |
GPU = 0 | |
GPU_t = 2 | |
# 降噪强度 -1=不降噪 // 0 // 1 // 2 // 3 | |
# 放大模型 0=upconv_7_anime_style_art_rgb // 1=upconv_7_photo // 2=cunet | |
# 指定加速的显卡 | |
# 显卡使用的线程 | |
if input.width > 2560 and input.height > 2560 : | |
raise Warning("源分辨率超过限制的范围,已临时禁用该脚本。") | |
cut1 = input.resize.Bilinear(format=vs.RGBS, matrix_in_s="709") | |
cut2 = core.w2xnvk.Waifu2x(clip=cut1, noise=denoise_lv, scale=2, model=scale_model, gpu_id=GPU, gpu_thread=GPU_t) | |
output = cut2.resize.Bilinear(format=fmt_fin, matrix_s="709", range=1 if colorlv==0 else None) | |
output.set_output() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment