aiqcamp commited on
Commit
d095bd7
β€’
1 Parent(s): 5c3e064

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -152,10 +152,13 @@ def start_tryon(dict, garm_img, garment_des, is_checked, is_checked_crop, denois
152
  mask, mask_gray = get_mask_location('hd', category, model_parse, keypoints)
153
  mask = mask.resize((768,1024))
154
  except NotImplementedError:
155
- status_message = f"μΉ΄ν…Œκ³ λ¦¬ {category}에 λŒ€ν•œ μžλ™ 마슀크 생성이 κ΅¬ν˜„λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. μ‚¬μš©μžκ°€ κ·Έλ¦° 마슀크λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€."
156
- mask = pil_to_binary_mask(dict['layers'][0].convert("RGB").resize((768, 1024)))
157
  else:
158
- mask = pil_to_binary_mask(dict['layers'][0].convert("RGB").resize((768, 1024)))
 
 
 
159
 
160
  mask_gray = (1-transforms.ToTensor()(mask)) * tensor_transfrom(human_img)
161
  mask_gray = to_pil_image((mask_gray+1.0)/2.0)
@@ -225,7 +228,12 @@ def start_tryon(dict, garm_img, garment_des, is_checked, is_checked_crop, denois
225
  width=768,
226
  ip_adapter_image = garm_img.resize((768,1024)),
227
  guidance_scale=2.0,
228
- )[0]
 
 
 
 
 
229
 
230
  if is_checked_crop:
231
  out_img = images[0].resize(crop_size)
@@ -294,9 +302,11 @@ with image_blocks as demo:
294
  with gr.Column():
295
  status_message = gr.Textbox(label="μƒνƒœ", interactive=False)
296
 
 
 
297
  try_button.click(fn=start_tryon,
298
  inputs=[imgs, garm_img, prompt, is_checked, is_checked_crop, denoise_steps, seed, category],
299
  outputs=[image_out, masked_img, status_message],
300
  api_name='tryon')
301
 
302
- image_blocks.launch(auth=("gini","pick"))
 
152
  mask, mask_gray = get_mask_location('hd', category, model_parse, keypoints)
153
  mask = mask.resize((768,1024))
154
  except NotImplementedError:
155
+ status_message = f"μΉ΄ν…Œκ³ λ¦¬ {category}에 λŒ€ν•œ μžλ™ 마슀크 생성이 κ΅¬ν˜„λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. κΈ°λ³Έ 마슀크λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€."
156
+ mask = Image.new('L', (768, 1024), 255)
157
  else:
158
+ if dict['layers'] and dict['layers'][0]:
159
+ mask = pil_to_binary_mask(dict['layers'][0].convert("RGB").resize((768, 1024)))
160
+ else:
161
+ mask = Image.new('L', (768, 1024), 255)
162
 
163
  mask_gray = (1-transforms.ToTensor()(mask)) * tensor_transfrom(human_img)
164
  mask_gray = to_pil_image((mask_gray+1.0)/2.0)
 
228
  width=768,
229
  ip_adapter_image = garm_img.resize((768,1024)),
230
  guidance_scale=2.0,
231
+ ).images
232
+
233
+ print(f"Mask shape: {mask.size}")
234
+ print(f"Human image shape: {human_img.size}")
235
+ print(f"Garment image shape: {garm_img.size}")
236
+ print(f"Output image shape: {images[0].size}")
237
 
238
  if is_checked_crop:
239
  out_img = images[0].resize(crop_size)
 
302
  with gr.Column():
303
  status_message = gr.Textbox(label="μƒνƒœ", interactive=False)
304
 
305
+
306
+
307
  try_button.click(fn=start_tryon,
308
  inputs=[imgs, garm_img, prompt, is_checked, is_checked_crop, denoise_steps, seed, category],
309
  outputs=[image_out, masked_img, status_message],
310
  api_name='tryon')
311
 
312
+ image_blocks.launch(auth=("gini","pick"))