Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -270,7 +270,7 @@ def infer(image_input):
|
|
| 270 |
|
| 271 |
gr.Info('Calling CLIP Interrogator ...')
|
| 272 |
|
| 273 |
-
yield None, None, None
|
| 274 |
clipi_result = clipi_client.predict(
|
| 275 |
image=handle_file(image_input),
|
| 276 |
mode="best",
|
|
@@ -285,11 +285,11 @@ def infer(image_input):
|
|
| 285 |
result = llama_gen_fragrance(llama_q)
|
| 286 |
|
| 287 |
print(f"Llama2 result: {result}")
|
| 288 |
-
yield result, None, None
|
| 289 |
|
| 290 |
parsed = parse_perfume_description(result)
|
| 291 |
image_desc = extract_field(parsed, "Image Description")
|
| 292 |
-
return result, parsed, image_desc
|
| 293 |
|
| 294 |
css="""
|
| 295 |
#col-container {max-width: 910px; margin-left: auto; margin-right: auto;}
|
|
@@ -315,17 +315,24 @@ with gr.Blocks(css=css) as demo:
|
|
| 315 |
get_flacon_btn = gr.Button("Generate Flacon image", interactive=False)
|
| 316 |
bottle_res = gr.Image(label="Flacon")
|
| 317 |
|
| 318 |
-
def
|
| 319 |
return gr.update(interactive=False)
|
|
|
|
|
|
|
|
|
|
| 320 |
|
| 321 |
submit_btn.click(
|
| 322 |
-
fn=
|
| 323 |
-
inputs =
|
| 324 |
outputs = [get_flacon_btn]
|
| 325 |
).then(
|
| 326 |
fn=infer,
|
| 327 |
inputs=[image_in],
|
| 328 |
-
outputs=[fragrance, json_res, flacon_desc
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
)
|
| 330 |
get_flacon_btn.click(fn=infer_flux, inputs=[flacon_desc], outputs=[bottle_res])
|
| 331 |
|
|
|
|
| 270 |
|
| 271 |
gr.Info('Calling CLIP Interrogator ...')
|
| 272 |
|
| 273 |
+
yield None, None, None
|
| 274 |
clipi_result = clipi_client.predict(
|
| 275 |
image=handle_file(image_input),
|
| 276 |
mode="best",
|
|
|
|
| 285 |
result = llama_gen_fragrance(llama_q)
|
| 286 |
|
| 287 |
print(f"Llama2 result: {result}")
|
| 288 |
+
yield result, None, None
|
| 289 |
|
| 290 |
parsed = parse_perfume_description(result)
|
| 291 |
image_desc = extract_field(parsed, "Image Description")
|
| 292 |
+
return result, parsed, image_desc
|
| 293 |
|
| 294 |
css="""
|
| 295 |
#col-container {max-width: 910px; margin-left: auto; margin-right: auto;}
|
|
|
|
| 315 |
get_flacon_btn = gr.Button("Generate Flacon image", interactive=False)
|
| 316 |
bottle_res = gr.Image(label="Flacon")
|
| 317 |
|
| 318 |
+
def disable_flacon_button():
|
| 319 |
return gr.update(interactive=False)
|
| 320 |
+
|
| 321 |
+
def allow_flacon_button():
|
| 322 |
+
return gr.update(interactive=True)
|
| 323 |
|
| 324 |
submit_btn.click(
|
| 325 |
+
fn=disable_flacon_button,
|
| 326 |
+
inputs = [],
|
| 327 |
outputs = [get_flacon_btn]
|
| 328 |
).then(
|
| 329 |
fn=infer,
|
| 330 |
inputs=[image_in],
|
| 331 |
+
outputs=[fragrance, json_res, flacon_desc]
|
| 332 |
+
).then(
|
| 333 |
+
fn=allow_flacon_button,
|
| 334 |
+
inputs=[],
|
| 335 |
+
outputs=[get_flacon_btn]
|
| 336 |
)
|
| 337 |
get_flacon_btn.click(fn=infer_flux, inputs=[flacon_desc], outputs=[bottle_res])
|
| 338 |
|