Spaces:
Runtime error
Runtime error
deployfix06
Browse files
app.py
CHANGED
|
@@ -15,7 +15,6 @@ from typing import List
|
|
| 15 |
|
| 16 |
|
| 17 |
import torch
|
| 18 |
-
import os
|
| 19 |
from transformers import AutoTokenizer
|
| 20 |
|
| 21 |
import numpy as np
|
|
@@ -43,7 +42,6 @@ def pil_to_binary_mask(pil_image, threshold=0):
|
|
| 43 |
|
| 44 |
|
| 45 |
base_path = 'yisol/IDM-VTON'
|
| 46 |
-
example_path = os.path.join(os.path.dirname(__file__), 'example')
|
| 47 |
|
| 48 |
unet = UNet2DConditionModel.from_pretrained(
|
| 49 |
base_path,
|
|
@@ -267,20 +265,6 @@ def start_tryon(dict, garm_img, garment_des, is_checked, is_checked_crop, denois
|
|
| 267 |
# 直接将生成的图片和mask调整到原始尺寸
|
| 268 |
return images[0].resize(orig_size), mask_gray.resize(orig_size)
|
| 269 |
|
| 270 |
-
garm_list = os.listdir(os.path.join(example_path,"cloth"))
|
| 271 |
-
garm_list_path = [os.path.join(example_path,"cloth",garm) for garm in garm_list]
|
| 272 |
-
|
| 273 |
-
human_list = os.listdir(os.path.join(example_path,"human"))
|
| 274 |
-
human_list_path = [os.path.join(example_path,"human",human) for human in human_list]
|
| 275 |
-
|
| 276 |
-
human_ex_list = []
|
| 277 |
-
for ex_human in human_list_path:
|
| 278 |
-
ex_dict= {}
|
| 279 |
-
ex_dict['background'] = ex_human
|
| 280 |
-
ex_dict['layers'] = None
|
| 281 |
-
ex_dict['composite'] = None
|
| 282 |
-
human_ex_list.append(ex_dict)
|
| 283 |
-
|
| 284 |
##default human
|
| 285 |
|
| 286 |
|
|
@@ -314,21 +298,14 @@ with image_blocks as demo:
|
|
| 314 |
with gr.Row():
|
| 315 |
is_checked_crop = gr.Checkbox(label="Yes", info="Use auto-crop & resizing",value=False)
|
| 316 |
|
| 317 |
-
|
| 318 |
-
inputs=imgs,
|
| 319 |
-
examples_per_page=15,
|
| 320 |
-
examples=human_ex_list
|
| 321 |
-
)
|
| 322 |
|
| 323 |
with gr.Column():
|
| 324 |
garm_img = gr.Image(label="Garment", sources='upload', type="pil")
|
| 325 |
with gr.Row(elem_id="prompt-container"):
|
| 326 |
with gr.Row():
|
| 327 |
prompt = gr.Textbox(label="Description of garment", placeholder="Short Sleeve Round Neck T-shirts", show_label=True, elem_id="prompt")
|
| 328 |
-
|
| 329 |
-
inputs=garm_img,
|
| 330 |
-
examples_per_page=16,
|
| 331 |
-
examples=garm_list_path)
|
| 332 |
with gr.Column():
|
| 333 |
# image_out = gr.Image(label="Output", elem_id="output-img", height=400)
|
| 334 |
masked_img = gr.Image(label="Masked image output", elem_id="masked-img",show_share_button=False)
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
import torch
|
|
|
|
| 18 |
from transformers import AutoTokenizer
|
| 19 |
|
| 20 |
import numpy as np
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
base_path = 'yisol/IDM-VTON'
|
|
|
|
| 45 |
|
| 46 |
unet = UNet2DConditionModel.from_pretrained(
|
| 47 |
base_path,
|
|
|
|
| 265 |
# 直接将生成的图片和mask调整到原始尺寸
|
| 266 |
return images[0].resize(orig_size), mask_gray.resize(orig_size)
|
| 267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
##default human
|
| 269 |
|
| 270 |
|
|
|
|
| 298 |
with gr.Row():
|
| 299 |
is_checked_crop = gr.Checkbox(label="Yes", info="Use auto-crop & resizing",value=False)
|
| 300 |
|
| 301 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
with gr.Column():
|
| 304 |
garm_img = gr.Image(label="Garment", sources='upload', type="pil")
|
| 305 |
with gr.Row(elem_id="prompt-container"):
|
| 306 |
with gr.Row():
|
| 307 |
prompt = gr.Textbox(label="Description of garment", placeholder="Short Sleeve Round Neck T-shirts", show_label=True, elem_id="prompt")
|
| 308 |
+
|
|
|
|
|
|
|
|
|
|
| 309 |
with gr.Column():
|
| 310 |
# image_out = gr.Image(label="Output", elem_id="output-img", height=400)
|
| 311 |
masked_img = gr.Image(label="Masked image output", elem_id="masked-img",show_share_button=False)
|