Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -155,14 +155,24 @@ def start_tryon(dict,garm_img,garment_des,is_checked,is_checked_crop,denoise_ste
|
|
155 |
|
156 |
# Calculate the cropping box
|
157 |
left = (width - target_width) / 2
|
158 |
-
top =
|
159 |
right = (width + target_width) / 2
|
160 |
-
bottom =
|
161 |
|
162 |
-
#
|
|
|
|
|
|
|
163 |
cropped_img = human_img_orig.crop((left, top, right, bottom))
|
164 |
crop_size = cropped_img.size
|
|
|
|
|
165 |
human_img = cropped_img.resize((768, 1024))
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
else:
|
168 |
human_img = human_img_orig.resize((768,1024))
|
|
|
155 |
|
156 |
# Calculate the cropping box
|
157 |
left = (width - target_width) / 2
|
158 |
+
top = 0 # Start from the top of the image to keep the face in view
|
159 |
right = (width + target_width) / 2
|
160 |
+
bottom = target_height
|
161 |
|
162 |
+
# Ensure bottom does not exceed image height
|
163 |
+
bottom = min(height, bottom)
|
164 |
+
|
165 |
+
# Crop the image
|
166 |
cropped_img = human_img_orig.crop((left, top, right, bottom))
|
167 |
crop_size = cropped_img.size
|
168 |
+
|
169 |
+
# Resize the cropped image
|
170 |
human_img = cropped_img.resize((768, 1024))
|
171 |
+
|
172 |
+
# Example usage of crop_size
|
173 |
+
out_img = images[0].resize(crop_size)
|
174 |
+
human_img_orig.paste(out_img, (int(left), int(top)))
|
175 |
+
|
176 |
|
177 |
else:
|
178 |
human_img = human_img_orig.resize((768,1024))
|