From 663c8c64ca5679eb0f192a10fb3a0fc540324ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neo=20=E5=AD=AB?= Date: Tue, 26 May 2026 00:11:20 +0800 Subject: [PATCH] fix(ctrlregen): correct module import paths (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CtrlRegen engine module references a non-existent top-level package 'ctrlregen' in four locations: src/remove_ai_watermarks/noai/ctrlregen/engine.py L39: from ctrlregen.pipeline import CustomCtrlRegenPipeline L57: from ctrlregen.color import color_match L242: from ctrlregen.tiling import resize_center_crop, run_tiled L267: from ctrlregen.tiling import resize_center_crop These should be absolute imports of the package's own subpackage. As a result, the top-level try/except sets _HAS_DIFFUSERS=False and _HAS_COLOR_MATCHER=False even when the [gpu] extra is correctly installed, and is_ctrlregen_available() always returns False. Effect on users: invoking the ctrlregen profile crashes with ImportError: Failed to auto-install missing dependencies: controlnet-aux, color-matcher, safetensors regardless of whether those packages are installed. The auto-install fallback also fails in uv-managed venvs (uv does not ship pip in the venv by default), so the error path is unrecoverable. Reproduction (before fix): uv sync --all-extras uv run remove-ai-watermarks invisible --pipeline ctrlregen # → ImportError as above Fix: change the four imports to use the package-qualified path (matching the absolute-import style used elsewhere in the codebase, e.g. watermark_remover.py). Verified post-fix on Linux/CUDA (NVIDIA L40S): - is_ctrlregen_available() returns True - CtrlRegen pipeline loads, downloads weights, and runs end-to-end - Tile-based path (image > 512px) processes 6 tiles cleanly - 142 existing pytest tests still pass --- src/remove_ai_watermarks/noai/ctrlregen/engine.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/remove_ai_watermarks/noai/ctrlregen/engine.py b/src/remove_ai_watermarks/noai/ctrlregen/engine.py index 31f5b75..be12225 100644 --- a/src/remove_ai_watermarks/noai/ctrlregen/engine.py +++ b/src/remove_ai_watermarks/noai/ctrlregen/engine.py @@ -36,7 +36,7 @@ _HAS_COLOR_MATCHER = False _HAS_DIFFUSERS = False try: - from ctrlregen.pipeline import CustomCtrlRegenPipeline + from remove_ai_watermarks.noai.ctrlregen.pipeline import CustomCtrlRegenPipeline from diffusers import AutoencoderKL, ControlNetModel, UniPCMultistepScheduler _HAS_DIFFUSERS = True @@ -54,7 +54,7 @@ except ImportError: CannyDetector = None # type: ignore[assignment,misc] try: - from ctrlregen.color import color_match + from remove_ai_watermarks.noai.ctrlregen.color import color_match _HAS_COLOR_MATCHER = True except ImportError: @@ -239,7 +239,7 @@ class CtrlRegenEngine: needs_tiling = orig_w > TILE_SIZE or orig_h > TILE_SIZE if needs_tiling: - from ctrlregen.tiling import resize_center_crop, run_tiled + from remove_ai_watermarks.noai.ctrlregen.tiling import resize_center_crop, run_tiled aligned_w = orig_w // 8 * 8 aligned_h = orig_h // 8 * 8 @@ -264,7 +264,7 @@ class CtrlRegenEngine: ip_adapter_image=orig_image, ) else: - from ctrlregen.tiling import resize_center_crop + from remove_ai_watermarks.noai.ctrlregen.tiling import resize_center_crop proc_image = resize_center_crop(image, PROCESS_SIZE) self._set_progress(f"Preprocessed {orig_w}x{orig_h}px → {proc_image.size[0]}x{proc_image.size[1]}px")