Update app.py
Browse files
app.py
CHANGED
|
@@ -185,7 +185,7 @@ def create_face_mask(image, bbox_coords, mode):
|
|
| 185 |
- padding_info: Dictionary mit Skalierungsinfo für späteres Compositing
|
| 186 |
"""
|
| 187 |
|
| 188 |
-
# Herunterskalierung von Bild und BBox auf 512x512 für ControlnetInpaint-Pipeline
|
| 189 |
def scale_image_and_mask_together(image, mask, target_size=512, bbox_coords=None, mode=None):
|
| 190 |
if image is None or mask is None:
|
| 191 |
raise ValueError("Bild oder Maske ist None")
|
|
@@ -1302,7 +1302,7 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 1302 |
|
| 1303 |
# === WICHTIGE ÄNDERUNG: SAM 2 STATT create_face_mask ===
|
| 1304 |
# 1. MASKE mit SAM 2 erzeugen (transparent für Benutzer)
|
| 1305 |
-
processed_mask, raw_mask = controlnet_processor.create_sam_mask(
|
| 1306 |
image=image,
|
| 1307 |
bbox_coords=(bbox_x1, bbox_y1, bbox_x2, bbox_y2),
|
| 1308 |
mode=mode
|
|
@@ -1313,7 +1313,8 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 1313 |
# 2. BILD UND MASKE GEMEINSAM SKALIEREN (mit Padding)
|
| 1314 |
scaled_image, scaled_mask, padding_info = scale_image_and_mask_together(
|
| 1315 |
image.convert("RGB"), # Originalbild
|
| 1316 |
-
|
|
|
|
| 1317 |
target_size=IMG_SIZE,
|
| 1318 |
bbox_coords=(bbox_x1, bbox_y1, bbox_x2, bbox_y2),
|
| 1319 |
mode=mode
|
|
|
|
| 185 |
- padding_info: Dictionary mit Skalierungsinfo für späteres Compositing
|
| 186 |
"""
|
| 187 |
|
| 188 |
+
# Herunterskalierung von Bild und BBox/SAM-Maske auf 512x512 für ControlnetInpaint-Pipeline
|
| 189 |
def scale_image_and_mask_together(image, mask, target_size=512, bbox_coords=None, mode=None):
|
| 190 |
if image is None or mask is None:
|
| 191 |
raise ValueError("Bild oder Maske ist None")
|
|
|
|
| 1302 |
|
| 1303 |
# === WICHTIGE ÄNDERUNG: SAM 2 STATT create_face_mask ===
|
| 1304 |
# 1. MASKE mit SAM 2 erzeugen (transparent für Benutzer)
|
| 1305 |
+
processed_mask, raw_mask, binary_mask = controlnet_processor.create_sam_mask(
|
| 1306 |
image=image,
|
| 1307 |
bbox_coords=(bbox_x1, bbox_y1, bbox_x2, bbox_y2),
|
| 1308 |
mode=mode
|
|
|
|
| 1313 |
# 2. BILD UND MASKE GEMEINSAM SKALIEREN (mit Padding)
|
| 1314 |
scaled_image, scaled_mask, padding_info = scale_image_and_mask_together(
|
| 1315 |
image.convert("RGB"), # Originalbild
|
| 1316 |
+
binary_mask, # SAM 2 Binärmaske ohne Blur
|
| 1317 |
+
original_mask, # SAM 2 Maske geglättet (oder Fallback)
|
| 1318 |
target_size=IMG_SIZE,
|
| 1319 |
bbox_coords=(bbox_x1, bbox_y1, bbox_x2, bbox_y2),
|
| 1320 |
mode=mode
|