Update controlnet_module.py
Browse files- controlnet_module.py +14 -7
controlnet_module.py
CHANGED
|
@@ -160,14 +160,21 @@ class ControlNetProcessor:
|
|
| 160 |
print(f"🔍 Reshaped_input_sizes parameter (in inputs): {inputs.get('reshaped_input_sizes', 'NOT FOUND')}")
|
| 161 |
|
| 162 |
|
| 163 |
-
#
|
| 164 |
-
#
|
| 165 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
mask = self.sam_processor.post_process_masks(
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
)[0][0] # [
|
|
|
|
| 171 |
|
| 172 |
# Sigmoid für Wahrscheinlichkeiten, dann Schwellenwert
|
| 173 |
mask = mask.sigmoid().cpu().numpy()
|
|
|
|
| 160 |
print(f"🔍 Reshaped_input_sizes parameter (in inputs): {inputs.get('reshaped_input_sizes', 'NOT FOUND')}")
|
| 161 |
|
| 162 |
|
| 163 |
+
# --- NEUEN CODE EINFÜGEN ---
|
| 164 |
+
# 1. Wähle nur die erste Maske aus den 3 Vorschlägen
|
| 165 |
+
single_mask = outputs.pred_masks[:, :, 0, :, :] # Shape wird [1, 1, 256, 256]
|
| 166 |
+
|
| 167 |
+
# 2. Konvertiere die Größen-Parameter zu CPU und als Python-Liste
|
| 168 |
+
original_size = inputs['original_sizes'].cpu().numpy().tolist()[0] # [512, 512]
|
| 169 |
+
input_size = inputs['reshaped_input_sizes'].cpu().numpy().tolist()[0] # [512, 512]
|
| 170 |
+
|
| 171 |
+
# 3. Korrekter Aufruf mit angepassten Parametern
|
| 172 |
mask = self.sam_processor.post_process_masks(
|
| 173 |
+
single_mask, # Nur eine Maske
|
| 174 |
+
original_sizes=[original_size], # Als Python-Liste
|
| 175 |
+
reshaped_input_sizes=[input_size] # Als Python-Liste
|
| 176 |
+
)[0][0] # [batch][mask]
|
| 177 |
+
|
| 178 |
|
| 179 |
# Sigmoid für Wahrscheinlichkeiten, dann Schwellenwert
|
| 180 |
mask = mask.sigmoid().cpu().numpy()
|