Zuii commited on
Commit
d68599b
Β·
verified Β·
1 Parent(s): 0d53021

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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
- 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}")
 
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}")