Skip to content

Commit

Permalink
LHzDelowpass: New model, change default kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
LightArrowsEXE committed Nov 5, 2024
1 parent 9d12eca commit d70d113
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lvsfunc/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from warnings import warn

from vsexprtools import expr_func
from vskernels import Catrom, Lanczos
from vskernels import Catrom, Point
from vsscale import autoselect_backend
from vstools import (ColorRange, CustomValueError, DependencyNotFoundError,
FileWasNotFoundError, FunctionUtil, Matrix, SPath, depth,
Expand Down Expand Up @@ -119,7 +119,7 @@ def _scale_based_on_planes(self, clip: vs.VideoNode) -> vs.VideoNode:
elif clip.format.subsampling_h == 4:
res_kwargs |= dict(height=clip.height // 8)

return Lanczos.resample(clip, **res_kwargs)
return Point.resample(clip, **res_kwargs)

def _apply_model(self, proc_clip: vs.VideoNode, ref: vs.VideoNode | None = None) -> vs.VideoNode:
"""Apply the model to the clip."""
Expand All @@ -138,7 +138,7 @@ def _apply_model(self, proc_clip: vs.VideoNode, ref: vs.VideoNode | None = None)
)

if ref is not None and ref.format.color_family != vs.RGB:
processed = Catrom(linear=True).resample(processed, ref, matrix=self._matrix)
processed = Point(linear=True).resample(processed, ref, matrix=self._matrix)

processed = self._select_planes(processed, ref)

Expand Down
19 changes: 15 additions & 4 deletions lvsfunc/models/delowpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class _LHzDelowpass(Base1xModel, ModelNumpyHandling):
Each model is trained on different lowpassing values.
As such, you may need to experiment to find the one that best suits your source.
Defaults to Double 4-taps (1.5, 1.5).
Note that some models will also by nature perform mpeg2 compression denoising.
If this effect is too strong, you should mask the output.
"""

def __str__(self):
Expand All @@ -45,7 +46,7 @@ def apply(
self,
clip: vs.VideoNode,
slice_size: int | None = None,
planes: PlanesT = 0,
planes: PlanesT = None,
**kwargs: Any
) -> vs.VideoNode:
"""
Expand All @@ -56,7 +57,7 @@ def apply(
This is currently very slow and takes up a ton of memory!
Only enable for testing purposes.
Default: Disable.
:param planes: The planes to apply the model to. Default: luma only.
:param planes: The planes to apply the model to. Default: all planes.
:param kwargs: Additional keyword arguments.
:return: The processed clip.
Expand Down Expand Up @@ -96,9 +97,19 @@ class LHzDelowpass(_LHzDelowpass):
@dataclass
class DoubleTaps_4_4_15_15(_LHzDelowpass):
"""
Lowpass model for R2J DVD horizontal lowpassing.
Lowpass model for common R2J DVD horizontal lowpassing.
Trained on double 4-taps (1.5, 1.5).
"""

_model_filename = '1x_lanczos_hz_delowpass_4_4_15_15_fp32.onnx'

@dataclass
class DoubleTaps_4_4_15_15_mpeg2(_LHzDelowpass):
"""
Lowpass model for common R2J DVD horizontal lowpassing.
Trained on double 4-taps (1.5, 1.5) + mpeg2 compression.
"""

_model_filename = '1x_lanczos_hz_delowpass_4_4_15_15_mpeg2_fp32.onnx'
Binary file not shown.

0 comments on commit d70d113

Please sign in to comment.