Spaces:
Runtime error
Runtime error
hasibzunair
commited on
Commit
β’
7c4840c
1
Parent(s):
ed22721
update
Browse files- app.py +9 -7
- gradio_queue.db-journal +0 -0
app.py
CHANGED
@@ -60,9 +60,6 @@ if not os.path.exists("saved_models/u2net/u2net.pth"):
|
|
60 |
# Get model checkpoints
|
61 |
if not os.path.exists("./checkpoints/decavtonfifapretrain/"):
|
62 |
os.system("wget -O ./checkpoints/decavtonfifapretrain.zip https://github.com/hasibzunair/vton-demo/releases/download/v1.0/decavtonfifapretrain.zip")
|
63 |
-
# Works locally
|
64 |
-
#os.system("sudo apt-get install zip unzip")
|
65 |
-
#os.system("unzip ./checkpoints/decavtonfifapretrain.zip -d ./checkpoints/")
|
66 |
with zipfile.ZipFile('./checkpoints/decavtonfifapretrain.zip', 'r') as zip_ref:
|
67 |
zip_ref.extractall('./checkpoints/')
|
68 |
|
@@ -95,10 +92,12 @@ def composite_background(img_mask, person_image_path, tryon_image_path):
|
|
95 |
|
96 |
|
97 |
# Main inference function
|
98 |
-
def inference(clothing_image, person_image,
|
99 |
"""
|
100 |
Do try-on!
|
101 |
"""
|
|
|
|
|
102 |
# Read cloth and person images
|
103 |
cloth = Image.open(clothing_image) # cloth
|
104 |
person = Image.open(person_image) # person
|
@@ -166,16 +165,19 @@ def inference(clothing_image, person_image, remove_bg, retrieve_bg):
|
|
166 |
return os.path.join("results/test/try-on/person.png")
|
167 |
|
168 |
|
169 |
-
title = "Virtual
|
170 |
-
description = "This is a demo for image based virtual try-on. It generates a synthetic image of a person wearing a target clothing item. To use it, simply upload your clothing item and person images, or click one of the examples to load them.
|
171 |
article = "<p style='text-align: center'><a href='will_be_added' target='_blank'>Fill in Fabrics: Body-Aware Self-Supervised Inpainting for Image-Based Virtual Try-On (Under Review!)</a> | <a href='https://github.com/dktunited/fifa_demo' target='_blank'>Github</a></p>"
|
172 |
thumbnail = None # "./pathtothumbnail.png"
|
173 |
|
|
|
|
|
|
|
|
|
174 |
gr.Interface(
|
175 |
inference,
|
176 |
[gr.inputs.Image(type='filepath', label="Clothing Image"),
|
177 |
gr.inputs.Image(type='filepath', label="Person Image"),
|
178 |
-
gr.inputs.Radio(choices=["yes","no"], default="no", label="Remove background from the person image?"),
|
179 |
gr.inputs.Radio(choices=["yes","no"], default="no", label="Retrieve original background from the person image?")],
|
180 |
gr.outputs.Image(type="filepath", label="Predicted Output"),
|
181 |
examples=[["./sample_images/1/cloth.jpg", "./sample_images/1/person.jpg"],
|
|
|
60 |
# Get model checkpoints
|
61 |
if not os.path.exists("./checkpoints/decavtonfifapretrain/"):
|
62 |
os.system("wget -O ./checkpoints/decavtonfifapretrain.zip https://github.com/hasibzunair/vton-demo/releases/download/v1.0/decavtonfifapretrain.zip")
|
|
|
|
|
|
|
63 |
with zipfile.ZipFile('./checkpoints/decavtonfifapretrain.zip', 'r') as zip_ref:
|
64 |
zip_ref.extractall('./checkpoints/')
|
65 |
|
|
|
92 |
|
93 |
|
94 |
# Main inference function
|
95 |
+
def inference(clothing_image, person_image, retrieve_bg):
|
96 |
"""
|
97 |
Do try-on!
|
98 |
"""
|
99 |
+
remove_bg = "no"
|
100 |
+
|
101 |
# Read cloth and person images
|
102 |
cloth = Image.open(clothing_image) # cloth
|
103 |
person = Image.open(person_image) # person
|
|
|
165 |
return os.path.join("results/test/try-on/person.png")
|
166 |
|
167 |
|
168 |
+
title = "Image based Virtual Try-On"
|
169 |
+
description = "This is a demo for an image based virtual try-on system. It generates a synthetic image of a person wearing a target clothing item. To use it, simply upload your clothing item and person images, or click one of the examples to load them."
|
170 |
article = "<p style='text-align: center'><a href='will_be_added' target='_blank'>Fill in Fabrics: Body-Aware Self-Supervised Inpainting for Image-Based Virtual Try-On (Under Review!)</a> | <a href='https://github.com/dktunited/fifa_demo' target='_blank'>Github</a></p>"
|
171 |
thumbnail = None # "./pathtothumbnail.png"
|
172 |
|
173 |
+
# todos
|
174 |
+
# train model with background removed then add feature, also add remove_bg in inferene()
|
175 |
+
# add gr.inputs.Radio(choices=["yes","no"], default="no", label="Remove background from the person image?") in inputs
|
176 |
+
|
177 |
gr.Interface(
|
178 |
inference,
|
179 |
[gr.inputs.Image(type='filepath', label="Clothing Image"),
|
180 |
gr.inputs.Image(type='filepath', label="Person Image"),
|
|
|
181 |
gr.inputs.Radio(choices=["yes","no"], default="no", label="Retrieve original background from the person image?")],
|
182 |
gr.outputs.Image(type="filepath", label="Predicted Output"),
|
183 |
examples=[["./sample_images/1/cloth.jpg", "./sample_images/1/person.jpg"],
|
gradio_queue.db-journal
DELETED
Binary file (512 Bytes)
|
|