mirror of
https://github.com/vladmandic/automatic
synced 2026-08-25 22:20:46 +02:00
76aa949a26
Vendor sharpfin library (Apache 2.0) and add centralized wrapper module (images_sharpfin.py) replacing torchvision tensor/PIL conversion and resize operations throughout the codebase. - Add modules/sharpfin/ vendored library with MKS2021, Lanczos3, Mitchell, Catmull-Rom kernels and optional Triton sparse acceleration - Add modules/images_sharpfin.py wrapper with to_tensor(), to_pil(), pil_to_tensor(), normalize(), resize(), resize_tensor() - Add resize_quality and resize_linearize_srgb settings - Add MKS2021 and Lanczos3 upscaler entries - Replace torchvision.transforms.functional imports across 18 files - to_pil() auto-detects HWC/BHWC layout, adds .round() before uint8 - Sparse Triton path falls back to dense GPU on compilation failure - Mixed-axis resize splits into two single-axis scale() calls - Masks and non-sRGB data always use linearize=False
21 lines
625 B
Python
21 lines
625 B
Python
"""Sharpfin - High quality image resizing with GPU acceleration.
|
|
|
|
Vendored from https://github.com/drhead/sharpfin (Apache 2.0)
|
|
Provides Magic Kernel Sharp 2021 resampling, sRGB linearization,
|
|
and Triton sparse GPU acceleration.
|
|
"""
|
|
|
|
from .util import ResizeKernel, SharpenKernel, QuantHandling, srgb_to_linear, linear_to_srgb
|
|
|
|
try:
|
|
from .functional import scale, _upscale, _downscale, _get_resize_kernel
|
|
FUNCTIONAL_AVAILABLE = True
|
|
except Exception:
|
|
FUNCTIONAL_AVAILABLE = False
|
|
|
|
try:
|
|
from .triton_functional import downscale_sparse
|
|
TRITON_AVAILABLE = True
|
|
except Exception:
|
|
TRITON_AVAILABLE = False
|