mikitona commited on
Commit
962c071
·
verified ·
1 Parent(s): 54759d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -122,7 +122,7 @@ pipe = TryonPipeline.from_pretrained(
122
  pipe.unet_encoder = UNet_Encoder
123
 
124
 
125
- @spaces.GPU(duration=90) # 実行時間を90秒に設定
126
  def start_tryon(
127
  dict, garm_img, garment_des, is_checked, is_checked_crop, denoise_steps, seed, num_images
128
  ):
@@ -212,8 +212,11 @@ def start_tryon(
212
  pose_img_tensor = tensor_transfrom(pose_img).unsqueeze(0).to(device, torch.float16)
213
  garm_tensor = tensor_transfrom(garm_img).unsqueeze(0).to(device, torch.float16)
214
 
 
 
 
215
  # 最初にマスク画像を一度だけ出力
216
- yield None, mask_gray
217
 
218
  for i in range(int(num_images)):
219
  current_seed = seed + i if seed is not None and seed != -1 else None
@@ -248,9 +251,18 @@ def start_tryon(
248
  out_img = images[0].resize(crop_size)
249
  human_img_copy = human_img_orig.copy()
250
  human_img_copy.paste(out_img, (int(left), int(top)))
251
- yield [human_img_copy], None
252
  else:
253
- yield [images[0]], None
 
 
 
 
 
 
 
 
 
254
 
255
 
256
  garm_list = os.listdir(os.path.join(example_path, "cloth"))
@@ -335,4 +347,4 @@ with image_blocks as demo:
335
  api_name='tryon',
336
  )
337
 
338
- image_blocks.launch()
 
122
  pipe.unet_encoder = UNet_Encoder
123
 
124
 
125
+ @spaces.GPU(duration=120) # 実行時間を120秒に設定
126
  def start_tryon(
127
  dict, garm_img, garment_des, is_checked, is_checked_crop, denoise_steps, seed, num_images
128
  ):
 
212
  pose_img_tensor = tensor_transfrom(pose_img).unsqueeze(0).to(device, torch.float16)
213
  garm_tensor = tensor_transfrom(garm_img).unsqueeze(0).to(device, torch.float16)
214
 
215
+ # 初期化
216
+ output_images = gr.State([])
217
+
218
  # 最初にマスク画像を一度だけ出力
219
+ yield output_images.value, mask_gray
220
 
221
  for i in range(int(num_images)):
222
  current_seed = seed + i if seed is not None and seed != -1 else None
 
251
  out_img = images[0].resize(crop_size)
252
  human_img_copy = human_img_orig.copy()
253
  human_img_copy.paste(out_img, (int(left), int(top)))
254
+ new_image = human_img_copy
255
  else:
256
+ new_image = images[0]
257
+
258
+ # 画像を追加
259
+ output_images.value.append(new_image)
260
+
261
+ # ギャラリーを更新
262
+ yield output_images.value, None
263
+
264
+ # 最終的な結果を返す
265
+ return output_images.value, None
266
 
267
 
268
  garm_list = os.listdir(os.path.join(example_path, "cloth"))
 
347
  api_name='tryon',
348
  )
349
 
350
+ image_blocks.launch(show_error=True)