Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -269,20 +269,20 @@ def infer(image_input):
|
|
| 269 |
print(clipi_result)
|
| 270 |
|
| 271 |
llama_q = clipi_result
|
| 272 |
-
yield None, None
|
| 273 |
|
| 274 |
gr.Info('Calling Llama2 ...')
|
| 275 |
result = llama_gen_fragrance(llama_q)
|
| 276 |
|
| 277 |
print(f"Llama2 result: {result}")
|
| 278 |
-
yield result, None
|
| 279 |
|
| 280 |
parsed = parse_perfume_description(result)
|
| 281 |
-
yield result, parsed
|
| 282 |
-
|
| 283 |
-
def generate_flacon(parsed, progress=gr.Progress(track_tqdm=True)):
|
| 284 |
image_desc = extract_field(parsed, "Image Description")
|
|
|
|
| 285 |
|
|
|
|
|
|
|
| 286 |
print(image_desc)
|
| 287 |
gr.Info("Generating a nice marketing image with FLUX...")
|
| 288 |
gen_bottle = infer_flux(image_desc)
|
|
@@ -305,14 +305,15 @@ with gr.Blocks(css=css) as demo:
|
|
| 305 |
with gr.Column():
|
| 306 |
image_in = gr.Image(label="Image input", type="filepath", elem_id="image-in")
|
| 307 |
submit_btn = gr.Button('Give me a Fragrance')
|
| 308 |
-
json_res = gr.JSON(label="JSON (for further usage)"
|
|
|
|
| 309 |
with gr.Column():
|
| 310 |
#caption = gr.Textbox(label="Generated Caption")
|
| 311 |
fragrance = gr.Textbox(label="generated Fragrance", elem_id="fragrance")
|
| 312 |
get_flacon_btn = gr.Button("Generate Flacon image")
|
| 313 |
bottle_res = gr.Image(label="Flacon")
|
| 314 |
|
| 315 |
-
submit_btn.click(fn=infer, inputs=[image_in], outputs=[fragrance, json_res])
|
| 316 |
-
get_flacon_btn.click(fn=generate_flacon, inputs=[
|
| 317 |
|
| 318 |
demo.queue(max_size=12).launch(ssr_mode=False, mcp_server=True)
|
|
|
|
| 269 |
print(clipi_result)
|
| 270 |
|
| 271 |
llama_q = clipi_result
|
| 272 |
+
yield None, None, None
|
| 273 |
|
| 274 |
gr.Info('Calling Llama2 ...')
|
| 275 |
result = llama_gen_fragrance(llama_q)
|
| 276 |
|
| 277 |
print(f"Llama2 result: {result}")
|
| 278 |
+
yield result, None, None
|
| 279 |
|
| 280 |
parsed = parse_perfume_description(result)
|
|
|
|
|
|
|
|
|
|
| 281 |
image_desc = extract_field(parsed, "Image Description")
|
| 282 |
+
yield result, parsed, image_desc
|
| 283 |
|
| 284 |
+
def generate_flacon(parsed, progress=gr.Progress(track_tqdm=True)):
|
| 285 |
+
|
| 286 |
print(image_desc)
|
| 287 |
gr.Info("Generating a nice marketing image with FLUX...")
|
| 288 |
gen_bottle = infer_flux(image_desc)
|
|
|
|
| 305 |
with gr.Column():
|
| 306 |
image_in = gr.Image(label="Image input", type="filepath", elem_id="image-in")
|
| 307 |
submit_btn = gr.Button('Give me a Fragrance')
|
| 308 |
+
json_res = gr.JSON(label="JSON (for further usage)")
|
| 309 |
+
flacon_desc = gr.Textbox(interactive=False, visible=False)
|
| 310 |
with gr.Column():
|
| 311 |
#caption = gr.Textbox(label="Generated Caption")
|
| 312 |
fragrance = gr.Textbox(label="generated Fragrance", elem_id="fragrance")
|
| 313 |
get_flacon_btn = gr.Button("Generate Flacon image")
|
| 314 |
bottle_res = gr.Image(label="Flacon")
|
| 315 |
|
| 316 |
+
submit_btn.click(fn=infer, inputs=[image_in], outputs=[fragrance, json_res, flacon_desc])
|
| 317 |
+
get_flacon_btn.click(fn=generate_flacon, inputs=[flacon_desc], outputs=[bottle_res])
|
| 318 |
|
| 319 |
demo.queue(max_size=12).launch(ssr_mode=False, mcp_server=True)
|