Files
KIMJUNGHOandClaude Sonnet 4.6 94929c6bd0 feat: v2.0.0 — Major refactor and node reorganization
## Nodes
- Unified node key prefix to Util* (UtilSwitch, UtilStringToList, etc.)
- Added UtilSaveFile: combined Save Text & Image node with batch/list support,
  shared counter, subfolder, INPUT_IS_LIST
- Added UtilJsonToList: JSON file/string to STRING list via dot-notation key
- Added UtilEmptyLatent channels param (16=Flux/Lumina/SD3, 4=SD/SDXL)
- Updated UtilLoadImageList: count-based dropdown selectors from Input folder
- Added CNStepControl, CNPreprocessor (canny/depth/lineart/openpose/mlsd)
- Added ImageCropResize, LoRAStepLoader
- Added SBPromptFilter (Claude API style/controlnet filtering)
- Removed layer_nodes.py, sampler_nodes.py (layer separation experiments)
- Removed experiments/ directory

## Dependencies
- Removed controlnet_aux — direct preprocessor implementations in preprocessors/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 10:56:17 +09:00

64 lines
1.7 KiB
Python

"""ControlNet preprocessors without controlnet_aux dependency."""
import torch
_detector_cache = {}
def _get_device():
"""Get the best available device for inference."""
if torch.cuda.is_available():
return torch.device("cuda")
if hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
return torch.device("mps")
return torch.device("cpu")
def get_detector(processor_id):
"""Get or create a cached detector instance. Lazy imports to avoid loading unused models."""
if processor_id in _detector_cache:
return _detector_cache[processor_id]
device = _get_device()
if processor_id == "canny":
from .canny import CannyDetector
detector = CannyDetector()
elif processor_id == "depth":
from .depth import MidasDetector
detector = MidasDetector.from_pretrained()
detector.model.to(device)
elif processor_id == "lineart":
from .lineart import LineartDetector
detector = LineartDetector.from_pretrained()
detector.model.to(device)
elif processor_id == "pose":
from .openpose import OpenposeDetector
detector = OpenposeDetector.from_pretrained()
detector.to(device)
elif processor_id == "mlsd":
from .mlsd import MLSDdetector
detector = MLSDdetector.from_pretrained()
detector.model.to(device)
else:
raise ValueError(f"Unknown preprocessor: {processor_id}")
_detector_cache[processor_id] = detector
return detector
PREPROCESSOR_IDS = ["canny", "depth", "lineart", "pose", "mlsd"]
CALL_PARAMS = {
"canny": {},
"depth": {},
"lineart": {"coarse": False},
"pose": {},
"mlsd": {},
}