soifunc 0.9.2__tar.gz → 0.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {soifunc-0.9.2 → soifunc-0.10.0}/PKG-INFO +1 -1
- {soifunc-0.9.2 → soifunc-0.10.0}/pyproject.toml +1 -1
- {soifunc-0.9.2 → soifunc-0.10.0}/soifunc/resize.py +16 -54
- {soifunc-0.9.2 → soifunc-0.10.0}/LICENSE +0 -0
- {soifunc-0.9.2 → soifunc-0.10.0}/README.md +0 -0
- {soifunc-0.9.2 → soifunc-0.10.0}/soifunc/__init__.py +0 -0
- {soifunc-0.9.2 → soifunc-0.10.0}/soifunc/deband.py +0 -0
- {soifunc-0.9.2 → soifunc-0.10.0}/soifunc/denoise.py +0 -0
- {soifunc-0.9.2 → soifunc-0.10.0}/soifunc/py.typed +0 -0
|
@@ -4,6 +4,7 @@ from dataclasses import dataclass
|
|
|
4
4
|
from inspect import getfullargspec
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
+
from vsaa.antialiasers.nnedi3 import Nnedi3SS
|
|
7
8
|
from vskernels import (
|
|
8
9
|
Catrom,
|
|
9
10
|
EwaLanczos,
|
|
@@ -13,8 +14,8 @@ from vskernels import (
|
|
|
13
14
|
ScalerT,
|
|
14
15
|
Spline36,
|
|
15
16
|
)
|
|
16
|
-
from vsscale import SSIM, GenericScaler, Waifu2x
|
|
17
|
-
from vstools import check_variable_format, join, vs
|
|
17
|
+
from vsscale import SSIM, ArtCNN, GenericScaler, Waifu2x
|
|
18
|
+
from vstools import check_variable_format, is_gpu_available, join, vs
|
|
18
19
|
|
|
19
20
|
__all__ = [
|
|
20
21
|
"good_resize",
|
|
@@ -22,43 +23,6 @@ __all__ = [
|
|
|
22
23
|
]
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
@dataclass
|
|
26
|
-
class GoodScaler(KeepArScaler):
|
|
27
|
-
"""High quality resizing filter based on opinionated defaults"""
|
|
28
|
-
|
|
29
|
-
def __init__(
|
|
30
|
-
self,
|
|
31
|
-
luma_scaler: ScalerT,
|
|
32
|
-
chroma_scaler: ScalerT,
|
|
33
|
-
**kwargs: Any,
|
|
34
|
-
) -> None:
|
|
35
|
-
self.scaler = HybridScaler(luma_scaler, chroma_scaler)
|
|
36
|
-
super().__init__(**kwargs)
|
|
37
|
-
|
|
38
|
-
@property
|
|
39
|
-
def kernel_radius(self) -> int:
|
|
40
|
-
return self.scaler.kernel_radius
|
|
41
|
-
|
|
42
|
-
def scale_function( # type:ignore
|
|
43
|
-
self,
|
|
44
|
-
clip: vs.VideoNode,
|
|
45
|
-
width: int,
|
|
46
|
-
height: int,
|
|
47
|
-
shift: tuple[float, float] = (0, 0),
|
|
48
|
-
**kwargs: Any,
|
|
49
|
-
) -> vs.VideoNode:
|
|
50
|
-
if (width, height) == (clip.width, clip.height):
|
|
51
|
-
return clip
|
|
52
|
-
|
|
53
|
-
anime = kwargs.get("anime", False)
|
|
54
|
-
gpu = kwargs.get("gpu", None)
|
|
55
|
-
use_waifu2x = kwargs.get("use_waifu2x", None)
|
|
56
|
-
|
|
57
|
-
if anime and use_waifu2x:
|
|
58
|
-
return Waifu2x(cuda=gpu).scale(clip, width, height, shift)
|
|
59
|
-
return self.scaler.scale(clip, width, height, shift)
|
|
60
|
-
|
|
61
|
-
|
|
62
26
|
def good_resize(
|
|
63
27
|
clip: vs.VideoNode,
|
|
64
28
|
width: int,
|
|
@@ -66,7 +30,6 @@ def good_resize(
|
|
|
66
30
|
shift: tuple[float, float] = (0, 0),
|
|
67
31
|
gpu: bool | None = None,
|
|
68
32
|
anime: bool = False,
|
|
69
|
-
use_waifu2x: bool = False,
|
|
70
33
|
) -> vs.VideoNode:
|
|
71
34
|
"""High quality resizing filter
|
|
72
35
|
|
|
@@ -81,34 +44,33 @@ def good_resize(
|
|
|
81
44
|
shift: tuple[float, float], optional
|
|
82
45
|
Horizontal and vertical amount of shift to apply.
|
|
83
46
|
gpu: bool, optional
|
|
84
|
-
Whether to allow usage of GPU for
|
|
47
|
+
Whether to allow usage of GPU for ArtCNN.
|
|
85
48
|
Defaults to None, which will auto-select based on available mlrt and hardware.
|
|
86
49
|
anime: bool, optional
|
|
87
50
|
Enables scalers that are better tuned toward anime.
|
|
88
51
|
Defaults to False.
|
|
89
|
-
use_waifu2x: bool, optional
|
|
90
|
-
Enables Waifu2x. Will fall back to EwaLanczos if this is False.
|
|
91
|
-
Defaults to False, since Waifu2x can be a pain to set up.
|
|
92
52
|
"""
|
|
93
53
|
|
|
54
|
+
if gpu is None:
|
|
55
|
+
gpu = is_gpu_available()
|
|
56
|
+
|
|
94
57
|
is_upscale = clip.width < width or clip.height < height
|
|
58
|
+
chroma_scaler = Spline36()
|
|
95
59
|
if anime:
|
|
96
|
-
if is_upscale
|
|
97
|
-
|
|
98
|
-
|
|
60
|
+
if is_upscale:
|
|
61
|
+
if gpu:
|
|
62
|
+
luma_scaler = ArtCNN()
|
|
63
|
+
else:
|
|
64
|
+
luma_scaler = Nnedi3SS(scaler=Hermite(sigmoid=True))
|
|
99
65
|
else:
|
|
100
|
-
|
|
101
|
-
luma_scaler = Catrom(sigmoid=True)
|
|
102
|
-
chroma_scaler = Catrom(sigmoid=True)
|
|
66
|
+
luma_scaler = Hermite(sigmoid=True)
|
|
103
67
|
elif is_upscale:
|
|
104
68
|
luma_scaler = EwaLanczos()
|
|
105
|
-
chroma_scaler = Spline36()
|
|
106
69
|
else:
|
|
107
70
|
luma_scaler = SSIM()
|
|
108
|
-
chroma_scaler = Spline36()
|
|
109
71
|
|
|
110
|
-
return
|
|
111
|
-
clip, width, height, shift=shift
|
|
72
|
+
return HybridScaler(luma_scaler, chroma_scaler).scale(
|
|
73
|
+
clip, width, height, shift=shift
|
|
112
74
|
)
|
|
113
75
|
|
|
114
76
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|