Spaces:
Build error
Build error
Update run/gradio_ootd.py
Browse files- run/gradio_ootd.py +153 -4
run/gradio_ootd.py
CHANGED
@@ -118,8 +118,157 @@ def process_dc(vton_img, garm_img, category, n_samples, n_steps, image_scale, se
|
|
118 |
return images
|
119 |
|
120 |
|
121 |
-
block = gr.
|
122 |
-
block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
|
125 |
-
block_dc.launch(api_name='generate')
|
|
|
118 |
return images
|
119 |
|
120 |
|
121 |
+
block = gr.Blocks().queue()
|
122 |
+
with block:
|
123 |
+
with gr.Row():
|
124 |
+
gr.Markdown("# OOTDiffusion Demo")
|
125 |
+
with gr.Row():
|
126 |
+
gr.Markdown("## Half-body")
|
127 |
+
with gr.Row():
|
128 |
+
gr.Markdown("***Support upper-body garments***")
|
129 |
+
with gr.Row():
|
130 |
+
with gr.Column():
|
131 |
+
vton_img = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_hd)
|
132 |
+
example = gr.Examples(
|
133 |
+
inputs=vton_img,
|
134 |
+
examples_per_page=14,
|
135 |
+
examples=[
|
136 |
+
os.path.join(example_path, 'model/model_1.png'),
|
137 |
+
os.path.join(example_path, 'model/model_2.png'),
|
138 |
+
os.path.join(example_path, 'model/model_3.png'),
|
139 |
+
os.path.join(example_path, 'model/model_4.png'),
|
140 |
+
os.path.join(example_path, 'model/model_5.png'),
|
141 |
+
os.path.join(example_path, 'model/model_6.png'),
|
142 |
+
os.path.join(example_path, 'model/model_7.png'),
|
143 |
+
os.path.join(example_path, 'model/01008_00.jpg'),
|
144 |
+
os.path.join(example_path, 'model/07966_00.jpg'),
|
145 |
+
os.path.join(example_path, 'model/05997_00.jpg'),
|
146 |
+
os.path.join(example_path, 'model/02849_00.jpg'),
|
147 |
+
os.path.join(example_path, 'model/14627_00.jpg'),
|
148 |
+
os.path.join(example_path, 'model/09597_00.jpg'),
|
149 |
+
os.path.join(example_path, 'model/01861_00.jpg'),
|
150 |
+
])
|
151 |
+
with gr.Column():
|
152 |
+
garm_img = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_hd)
|
153 |
+
example = gr.Examples(
|
154 |
+
inputs=garm_img,
|
155 |
+
examples_per_page=14,
|
156 |
+
examples=[
|
157 |
+
os.path.join(example_path, 'garment/03244_00.jpg'),
|
158 |
+
os.path.join(example_path, 'garment/00126_00.jpg'),
|
159 |
+
os.path.join(example_path, 'garment/03032_00.jpg'),
|
160 |
+
os.path.join(example_path, 'garment/06123_00.jpg'),
|
161 |
+
os.path.join(example_path, 'garment/02305_00.jpg'),
|
162 |
+
os.path.join(example_path, 'garment/00055_00.jpg'),
|
163 |
+
os.path.join(example_path, 'garment/00470_00.jpg'),
|
164 |
+
os.path.join(example_path, 'garment/02015_00.jpg'),
|
165 |
+
os.path.join(example_path, 'garment/10297_00.jpg'),
|
166 |
+
os.path.join(example_path, 'garment/07382_00.jpg'),
|
167 |
+
os.path.join(example_path, 'garment/07764_00.jpg'),
|
168 |
+
os.path.join(example_path, 'garment/00151_00.jpg'),
|
169 |
+
os.path.join(example_path, 'garment/12562_00.jpg'),
|
170 |
+
os.path.join(example_path, 'garment/04825_00.jpg'),
|
171 |
+
])
|
172 |
+
with gr.Column():
|
173 |
+
result_gallery = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
174 |
+
with gr.Column():
|
175 |
+
run_button = gr.Button(value="Run")
|
176 |
+
n_samples = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1)
|
177 |
+
n_steps = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1)
|
178 |
+
# scale = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
179 |
+
image_scale = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
180 |
+
seed = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
181 |
+
|
182 |
+
ips = [vton_img, garm_img, n_samples, n_steps, image_scale, seed]
|
183 |
+
run_button.click(fn=process_hd, inputs=ips, outputs=[result_gallery], , api_name='generate_hc')
|
184 |
+
|
185 |
+
|
186 |
+
with gr.Row():
|
187 |
+
gr.Markdown("## Full-body")
|
188 |
+
with gr.Row():
|
189 |
+
gr.Markdown("***Support upper-body/lower-body/dresses; garment category must be paired!!!***")
|
190 |
+
with gr.Row():
|
191 |
+
with gr.Column():
|
192 |
+
vton_img_dc = gr.Image(label="Model", sources='upload', type="filepath", height=384, value=model_dc)
|
193 |
+
example = gr.Examples(
|
194 |
+
label="Examples (upper-body/lower-body)",
|
195 |
+
inputs=vton_img_dc,
|
196 |
+
examples_per_page=7,
|
197 |
+
examples=[
|
198 |
+
os.path.join(example_path, 'model/model_8.png'),
|
199 |
+
os.path.join(example_path, 'model/049447_0.jpg'),
|
200 |
+
os.path.join(example_path, 'model/049713_0.jpg'),
|
201 |
+
os.path.join(example_path, 'model/051482_0.jpg'),
|
202 |
+
os.path.join(example_path, 'model/051918_0.jpg'),
|
203 |
+
os.path.join(example_path, 'model/051962_0.jpg'),
|
204 |
+
os.path.join(example_path, 'model/049205_0.jpg'),
|
205 |
+
])
|
206 |
+
example = gr.Examples(
|
207 |
+
label="Examples (dress)",
|
208 |
+
inputs=vton_img_dc,
|
209 |
+
examples_per_page=7,
|
210 |
+
examples=[
|
211 |
+
os.path.join(example_path, 'model/model_9.png'),
|
212 |
+
os.path.join(example_path, 'model/052767_0.jpg'),
|
213 |
+
os.path.join(example_path, 'model/052472_0.jpg'),
|
214 |
+
os.path.join(example_path, 'model/053514_0.jpg'),
|
215 |
+
os.path.join(example_path, 'model/053228_0.jpg'),
|
216 |
+
os.path.join(example_path, 'model/052964_0.jpg'),
|
217 |
+
os.path.join(example_path, 'model/053700_0.jpg'),
|
218 |
+
])
|
219 |
+
with gr.Column():
|
220 |
+
garm_img_dc = gr.Image(label="Garment", sources='upload', type="filepath", height=384, value=garment_dc)
|
221 |
+
category_dc = gr.Dropdown(label="Garment category (important option!!!)", choices=["Upper-body", "Lower-body", "Dress"], value="Upper-body")
|
222 |
+
example = gr.Examples(
|
223 |
+
label="Examples (upper-body)",
|
224 |
+
inputs=garm_img_dc,
|
225 |
+
examples_per_page=7,
|
226 |
+
examples=[
|
227 |
+
os.path.join(example_path, 'garment/048554_1.jpg'),
|
228 |
+
os.path.join(example_path, 'garment/049920_1.jpg'),
|
229 |
+
os.path.join(example_path, 'garment/049965_1.jpg'),
|
230 |
+
os.path.join(example_path, 'garment/049949_1.jpg'),
|
231 |
+
os.path.join(example_path, 'garment/050181_1.jpg'),
|
232 |
+
os.path.join(example_path, 'garment/049805_1.jpg'),
|
233 |
+
os.path.join(example_path, 'garment/050105_1.jpg'),
|
234 |
+
])
|
235 |
+
example = gr.Examples(
|
236 |
+
label="Examples (lower-body)",
|
237 |
+
inputs=garm_img_dc,
|
238 |
+
examples_per_page=7,
|
239 |
+
examples=[
|
240 |
+
os.path.join(example_path, 'garment/051827_1.jpg'),
|
241 |
+
os.path.join(example_path, 'garment/051946_1.jpg'),
|
242 |
+
os.path.join(example_path, 'garment/051473_1.jpg'),
|
243 |
+
os.path.join(example_path, 'garment/051515_1.jpg'),
|
244 |
+
os.path.join(example_path, 'garment/051517_1.jpg'),
|
245 |
+
os.path.join(example_path, 'garment/051988_1.jpg'),
|
246 |
+
os.path.join(example_path, 'garment/051412_1.jpg'),
|
247 |
+
])
|
248 |
+
example = gr.Examples(
|
249 |
+
label="Examples (dress)",
|
250 |
+
inputs=garm_img_dc,
|
251 |
+
examples_per_page=7,
|
252 |
+
examples=[
|
253 |
+
os.path.join(example_path, 'garment/053290_1.jpg'),
|
254 |
+
os.path.join(example_path, 'garment/053744_1.jpg'),
|
255 |
+
os.path.join(example_path, 'garment/053742_1.jpg'),
|
256 |
+
os.path.join(example_path, 'garment/053786_1.jpg'),
|
257 |
+
os.path.join(example_path, 'garment/053790_1.jpg'),
|
258 |
+
os.path.join(example_path, 'garment/053319_1.jpg'),
|
259 |
+
os.path.join(example_path, 'garment/052234_1.jpg'),
|
260 |
+
])
|
261 |
+
with gr.Column():
|
262 |
+
result_gallery_dc = gr.Gallery(label='Output', show_label=False, elem_id="gallery", preview=True, scale=1)
|
263 |
+
with gr.Column():
|
264 |
+
run_button_dc = gr.Button(value="Run")
|
265 |
+
n_samples_dc = gr.Slider(label="Images", minimum=1, maximum=4, value=1, step=1)
|
266 |
+
n_steps_dc = gr.Slider(label="Steps", minimum=20, maximum=40, value=20, step=1)
|
267 |
+
# scale_dc = gr.Slider(label="Scale", minimum=1.0, maximum=12.0, value=5.0, step=0.1)
|
268 |
+
image_scale_dc = gr.Slider(label="Guidance scale", minimum=1.0, maximum=5.0, value=2.0, step=0.1)
|
269 |
+
seed_dc = gr.Slider(label="Seed", minimum=-1, maximum=2147483647, step=1, value=-1)
|
270 |
+
|
271 |
+
ips_dc = [vton_img_dc, garm_img_dc, category_dc, n_samples_dc, n_steps_dc, image_scale_dc, seed_dc]
|
272 |
+
run_button_dc.click(fn=process_dc, inputs=ips_dc, outputs=[result_gallery_dc] , api_name='generate_dc')
|
273 |
|
274 |
+
block.launch(show_api=True, share=True)
|
|