Update app.py
Browse files
app.py
CHANGED
@@ -61,24 +61,24 @@ def tryon(person_img, cloth_img, seed, random_seed):
|
|
61 |
person_img = cv2.resize(person_img, (256, 256))
|
62 |
cloth_img = cv2.resize(cloth_img, (256, 256))
|
63 |
|
64 |
-
|
65 |
# π₯ Blend garment onto person (simple overlay β still has blue tint)
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
# Position the garment roughly on the torso (manual offset)
|
71 |
-
|
72 |
-
|
73 |
|
74 |
# β
Ensure garment fits inside the person image
|
75 |
-
|
76 |
-
|
77 |
|
78 |
# π οΈ Add garment onto person (no transparency support β raw overlay)
|
79 |
-
|
80 |
|
81 |
-
|
82 |
|
83 |
except Exception as e:
|
84 |
print(f"β Error in tryon function: {e}")
|
|
|
61 |
person_img = cv2.resize(person_img, (256, 256))
|
62 |
cloth_img = cv2.resize(cloth_img, (256, 256))
|
63 |
|
64 |
+
try:
|
65 |
# π₯ Blend garment onto person (simple overlay β still has blue tint)
|
66 |
+
output_img = person_img.copy()
|
67 |
+
h, w, _ = person_img.shape
|
68 |
+
g_h, g_w, _ = cloth_img.shape
|
69 |
|
70 |
# Position the garment roughly on the torso (manual offset)
|
71 |
+
x_offset = (w - g_w) // 2
|
72 |
+
y_offset = int(h * 0.35)
|
73 |
|
74 |
# β
Ensure garment fits inside the person image
|
75 |
+
if y_offset + g_h > h or x_offset + g_w > w:
|
76 |
+
raise ValueError("β Garment image is too large for the person image!")
|
77 |
|
78 |
# π οΈ Add garment onto person (no transparency support β raw overlay)
|
79 |
+
output_img[y_offset:y_offset + g_h, x_offset:x_offset + g_w] = cloth_img
|
80 |
|
81 |
+
return output_img, seed, "β
Success (Blue tint + Garment added)"
|
82 |
|
83 |
except Exception as e:
|
84 |
print(f"β Error in tryon function: {e}")
|