Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts/vsmlrt.py: add support for esrgan janai models #42

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions scripts/vsmlrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ class RealESRGANModel(enum.IntEnum):
animevideo_xsx4 = 1
# v3
animevideov3 = 2 # 4x
# contributed: janai(2x) https://github.com/the-database/mpv-upscale-2x_animejanai/releases/tag/1.0.0 maintainer: hooke007
animejanaiL1_sharp = 5000
animejanaiL2_std = 5001
animejanaiL2_sharp = 5002
animejanaiL3_std = 5003
animejanaiL3_sharp = 5004

RealESRGANv2Model = RealESRGANModel

Expand All @@ -476,7 +482,7 @@ def RealESRGAN(
tiles: typing.Optional[typing.Union[int, typing.Tuple[int, int]]] = None,
tilesize: typing.Optional[typing.Union[int, typing.Tuple[int, int]]] = None,
overlap: typing.Optional[typing.Union[int, typing.Tuple[int, int]]] = None,
model: typing.Literal[0, 1, 2] = 0,
model: RealESRGANv2Model = 0,
backend: backendT = Backend.OV_CPU(),
scale: typing.Optional[float] = None
) -> vs.VideoNode:
Expand All @@ -493,7 +499,7 @@ def RealESRGAN(
raise ValueError(f'{func_name}: "clip" must be of RGB color family')

if not isinstance(model, int) or model not in RealESRGANv2Model.__members__.values():
raise ValueError(f'{func_name}: "model" must be 0, 1 or 2')
raise ValueError(f'{func_name}: invalid "model"')

if overlap is None:
overlap_w = overlap_h = 8
Expand Down Expand Up @@ -528,6 +534,12 @@ def RealESRGAN(
"RealESRGANv2",
"realesr-animevideov3.onnx"
)
elif model in [5000, 5001, 5002, 5003, 5004]:
network_path = os.path.join(
models_path,
"RealESRGANv2",
f"{RealESRGANv2Model(model).name}.onnx".replace('_', '-')
)

clip_org = clip
clip = inference_with_fallback(
Expand Down