Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Includes 30 custom nodes committed directly, 7 Civitai-exclusive loras stored via Git LFS, and a setup script that installs all dependencies and downloads HuggingFace-hosted models on vast.ai. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from PIL import Image
|
|
from usdu_utils import tensor_to_pil, pil_to_tensor
|
|
from comfy_extras.nodes_upscale_model import ImageUpscaleWithModel
|
|
from modules import shared
|
|
|
|
if (not hasattr(Image, 'Resampling')): # For older versions of Pillow
|
|
Image.Resampling = Image
|
|
|
|
|
|
class Upscaler:
|
|
|
|
def upscale(self, img: Image, scale, selected_model: str = None):
|
|
if scale == 1.0:
|
|
return img
|
|
if (shared.actual_upscaler is None):
|
|
return img.resize((img.width * scale, img.height * scale), Image.Resampling.LANCZOS)
|
|
if "execute" in dir(ImageUpscaleWithModel):
|
|
# V3 schema: https://github.com/comfyanonymous/ComfyUI/pull/10149
|
|
(upscaled,) = ImageUpscaleWithModel.execute(shared.actual_upscaler, shared.batch_as_tensor)
|
|
else:
|
|
(upscaled,) = ImageUpscaleWithModel().upscale(shared.actual_upscaler, shared.batch_as_tensor)
|
|
shared.batch = [tensor_to_pil(upscaled, i) for i in range(len(upscaled))]
|
|
return shared.batch[0]
|
|
|
|
|
|
class UpscalerData:
|
|
name = ""
|
|
data_path = ""
|
|
|
|
def __init__(self):
|
|
self.scaler = Upscaler()
|