Astridkraft commited on
Commit
9a70785
·
verified ·
1 Parent(s): 41351c1

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +0 -48
controlnet_module.py CHANGED
@@ -1158,54 +1158,6 @@ class ControlNetProcessor:
1158
  raw_mask_crop_pil = Image.fromarray(raw_mask_array).convert("L")
1159
  raw_mask_original = Image.new("L", original_image.size, 0)
1160
  raw_mask_original.paste(raw_mask_crop_pil, (crop_x1, crop_y1))
1161
-
1162
-
1163
- ###################################
1164
- # Erweiterung der Maske damit mehr Kontext für Inpaint
1165
- # damit in der BBox keine andere "Jacke" generiert wird
1166
- # #################################
1167
- print("👤 FACE_ONLY_CHANGE: Erweitere SAM-Maske um 50%")
1168
-
1169
- # Originalmaske kopieren (für Debug/Anzeige behalten)
1170
- original_precise_mask = mask_original.copy()
1171
-
1172
- # 1. Auf 150% vergrößern
1173
- expansion_factor = 1.5 # 50% größer
1174
- expanded_width = int(mask_original.width * expansion_factor)
1175
- expanded_height = int(mask_original.height * expansion_factor)
1176
-
1177
- expanded_mask_large = mask_original.resize(
1178
- (expanded_width, expanded_height),
1179
- Image.Resampling.LANCZOS
1180
- )
1181
-
1182
- # 2. Wieder auf Originalgröße zentriert zurücksetzen
1183
- mask_original = Image.new("L", original_image.size, 0)
1184
-
1185
- # Negative Offsets = Maske wird über Bildrand hinaus gelegt
1186
- x_offset = (expanded_width - mask_original.width) // 2
1187
- y_offset = (expanded_height - mask_original.height) // 2
1188
-
1189
- mask_original.paste(expanded_mask_large, (-x_offset, -y_offset))
1190
-
1191
- # 3. Weichzeichnen für natürliche Übergänge
1192
- mask_original = mask_original.filter(ImageFilter.GaussianBlur(10))
1193
-
1194
- print(f"✅ SAM-Maske erweitert: {original_precise_mask.size} → effektiv 150%")
1195
- print(f" Offsets: x={-x_offset}, y={-y_offset}")
1196
-
1197
- # RAW-Maske ebenfalls erweitern (für Debug-Anzeige)
1198
- raw_mask_expanded = raw_mask_original.resize(
1199
- (int(raw_mask_original.width * 1.3), int(raw_mask_original.height * 1.3)),
1200
- Image.Resampling.NEAREST
1201
- )
1202
- temp = Image.new("L", original_image.size, 0)
1203
- # WICHTIG: Original-Position + Offset
1204
- new_x = crop_x1 - 15
1205
- new_y = crop_y1 - 15
1206
- temp.paste(raw_mask_expanded, (new_x, new_y))
1207
-
1208
- raw_mask_original = temp
1209
 
1210
  # ============================================================
1211
  # ABSCHLIESSENDE STATISTIK
 
1158
  raw_mask_crop_pil = Image.fromarray(raw_mask_array).convert("L")
1159
  raw_mask_original = Image.new("L", original_image.size, 0)
1160
  raw_mask_original.paste(raw_mask_crop_pil, (crop_x1, crop_y1))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1161
 
1162
  # ============================================================
1163
  # ABSCHLIESSENDE STATISTIK