Skip to content

Commit

Permalink
scripts/vsmlrt.py: add support for esrgan janai models (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
hooke007 authored Apr 25, 2023
1 parent 92d04fc commit 9b23e40
Showing 1 changed file with 14 additions and 2 deletions.
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

0 comments on commit 9b23e40

Please sign in to comment.