Files
cedarconnor-upsampler/nodes.py
T
Claude Code 86fe6525bf Add minimal test version to diagnose loading issues
- Simplified nodes with minimal dependencies
- Removed all Google Drive functionality temporarily
- Basic structure only - just returns input image
- This will help isolate the import problem

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-23 20:18:34 -07:00

129 lines
5.0 KiB
Python

import os
import requests
import time
import tempfile
from typing import Tuple, Optional, Dict, Any
from urllib.parse import urlparse
from PIL import Image
import torch
import numpy as np
# Try to import ComfyUI modules with error handling
try:
import folder_paths
from comfy.utils import ProgressBar
COMFYUI_AVAILABLE = True
except ImportError as e:
print(f"ComfyUI imports failed: {e}")
COMFYUI_AVAILABLE = False
# Create dummy ProgressBar for testing
class ProgressBar:
def __init__(self, total):
self.total = total
def update(self, value):
pass
# Simple test - just basic ImgBB functionality
class UpsamplerSmartUpscale:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
"api_key": ("STRING", {"multiline": False}),
"input_image_type": (["realism", "anime", "universal"],),
"upscale_factor": ("FLOAT", {"default": 2.0, "min": 1.0, "max": 4.0, "step": 0.1}),
"global_creativity": ("INT", {"default": 5, "min": 0, "max": 10}),
"detail": ("INT", {"default": 5, "min": 0, "max": 10}),
},
"optional": {
"imgbb_api_key": ("STRING", {"multiline": False, "default": ""}),
"description": ("STRING", {"multiline": True, "default": ""}),
"should_enhance_faces": ("BOOLEAN", {"default": False}),
"should_preserve_blur": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("upscaled_image",)
FUNCTION = "upscale"
CATEGORY = "Upsampler"
def upscale(self, image: torch.Tensor, api_key: str, input_image_type: str,
upscale_factor: float, global_creativity: int, detail: int,
imgbb_api_key: str = "", description: str = "", should_enhance_faces: bool = False,
should_preserve_blur: bool = False) -> Tuple[torch.Tensor]:
print(f"🚀 [Upsampler] Starting minimal test...")
# Just return the input image for now - this is a test
return (image,)
class UpsamplerDynamicUpscale:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
"api_key": ("STRING", {"multiline": False}),
"input_image_type": (["realism", "anime", "universal"],),
"upscale_factor": ("FLOAT", {"default": 2.0, "min": 1.0, "max": 4.0, "step": 0.1}),
"global_creativity": ("INT", {"default": 5, "min": 0, "max": 10}),
"resemblance": ("INT", {"default": 8, "min": 0, "max": 10}),
"detail": ("INT", {"default": 5, "min": 0, "max": 10}),
},
"optional": {
"imgbb_api_key": ("STRING", {"multiline": False, "default": ""}),
"description": ("STRING", {"multiline": True, "default": ""}),
"should_enhance_faces": ("BOOLEAN", {"default": False}),
"should_preserve_hands": ("BOOLEAN", {"default": False}),
"should_preserve_blur": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("upscaled_image",)
FUNCTION = "upscale"
CATEGORY = "Upsampler"
def upscale(self, image: torch.Tensor, api_key: str, input_image_type: str,
upscale_factor: float, global_creativity: int, resemblance: int,
detail: int, imgbb_api_key: str = "", description: str = "", should_enhance_faces: bool = False,
should_preserve_hands: bool = False, should_preserve_blur: bool = False) -> Tuple[torch.Tensor]:
print(f"🚀 [Upsampler] Starting dynamic test...")
return (image,)
class UpsamplerPreciseUpscale:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": ("IMAGE",),
"api_key": ("STRING", {"multiline": False}),
"input_image_type": (["realism", "anime", "universal"],),
"upscale_factor": ("FLOAT", {"default": 4.0, "min": 1.0, "max": 16.0, "step": 0.1}),
},
"optional": {
"imgbb_api_key": ("STRING", {"multiline": False, "default": ""}),
"should_enhance_faces": ("BOOLEAN", {"default": False}),
"should_preserve_blur": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("upscaled_image",)
FUNCTION = "upscale"
CATEGORY = "Upsampler"
def upscale(self, image: torch.Tensor, api_key: str, input_image_type: str,
upscale_factor: float, imgbb_api_key: str = "", should_enhance_faces: bool = False,
should_preserve_blur: bool = False) -> Tuple[torch.Tensor]:
print(f"🚀 [Upsampler] Starting precise test...")
return (image,)
print("✅ Minimal nodes loaded successfully")