Spaces:
Running
on
Zero
Running
on
Zero
Update model.py
Browse files
model.py
CHANGED
|
@@ -79,10 +79,31 @@ class ModelHandler:
|
|
| 79 |
)
|
| 80 |
print(" [OK] Loaded InstantID ControlNet.")
|
| 81 |
|
| 82 |
-
# Load other ControlNets normally
|
| 83 |
print("Loading Depth and Edge ControlNets...")
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# --- Manually wrap the list of models in a MultiControlNetModel ---
|
| 87 |
print("Wrapping ControlNets in MultiControlNetModel...")
|
| 88 |
controlnet_list = [cn_instantid, cn_depth, cn_edge]
|
|
@@ -153,6 +174,8 @@ class ModelHandler:
|
|
| 153 |
# print(f" [WARNING] torch.compile failed: {e}. Running without compilation.")
|
| 154 |
|
| 155 |
# 6. Load Preprocessors
|
|
|
|
|
|
|
| 156 |
print("Loading Preprocessors (Zoe, LineArt)...")
|
| 157 |
self.depth_detector = Processor(Config.DEPTH)
|
| 158 |
self.edge_detector = Processor(Config.EDGE)
|
|
|
|
| 79 |
)
|
| 80 |
print(" [OK] Loaded InstantID ControlNet.")
|
| 81 |
|
|
|
|
| 82 |
print("Loading Depth and Edge ControlNets...")
|
| 83 |
+
|
| 84 |
+
# --- FIX: Load the actual ControlNetModels, not the 'controlnet-aux' Processors ---
|
| 85 |
+
# The 'Processor' class is for pre-processing (creating the maps),
|
| 86 |
+
# not for the model itself. Your Config.DEPTH ("lesres++") is an ID
|
| 87 |
+
# for the pre-processor, which is correctly used at the end of this file.
|
| 88 |
+
|
| 89 |
+
# Define the repo IDs for the standard SDXL ControlNet models
|
| 90 |
+
DEPTH_MODEL_REPO = "diffusers/controlnet-depth-sdxl-1.0"
|
| 91 |
+
EDGE_MODEL_REPO = "diffusers/controlnet-lineart-sdxl-1.0" # Matches "LineArt" in your print statements
|
| 92 |
+
|
| 93 |
+
cn_depth = ControlNetModel.from_pretrained(
|
| 94 |
+
DEPTH_MODEL_REPO,
|
| 95 |
+
torch_dtype=Config.DTYPE
|
| 96 |
+
)
|
| 97 |
+
print(f" [OK] Loaded Depth ControlNet ({DEPTH_MODEL_REPO}).")
|
| 98 |
+
|
| 99 |
+
cn_edge = ControlNetModel.from_pretrained(
|
| 100 |
+
EDGE_MODEL_REPO,
|
| 101 |
+
torch_dtype=Config.DTYPE
|
| 102 |
+
)
|
| 103 |
+
print(f" [OK] Loaded Edge/LineArt ControlNet ({EDGE_MODEL_REPO}).")
|
| 104 |
+
|
| 105 |
+
# --- End fix ---
|
| 106 |
+
|
| 107 |
# --- Manually wrap the list of models in a MultiControlNetModel ---
|
| 108 |
print("Wrapping ControlNets in MultiControlNetModel...")
|
| 109 |
controlnet_list = [cn_instantid, cn_depth, cn_edge]
|
|
|
|
| 174 |
# print(f" [WARNING] torch.compile failed: {e}. Running without compilation.")
|
| 175 |
|
| 176 |
# 6. Load Preprocessors
|
| 177 |
+
# This is the CORRECT place to use the 'Processor' class
|
| 178 |
+
# Config.DEPTH ("lesres++") and Config.EDGE are the annotator IDs
|
| 179 |
print("Loading Preprocessors (Zoe, LineArt)...")
|
| 180 |
self.depth_detector = Processor(Config.DEPTH)
|
| 181 |
self.edge_detector = Processor(Config.EDGE)
|