Hug0endob commited on
Commit
89282a4
·
verified ·
1 Parent(s): c48daf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -443,7 +443,6 @@ def load_preview(url: str):
443
  except Exception:
444
  return None, None, "Preview failed"
445
 
446
-
447
  with gr.Blocks(title="Flux", css=css) as demo:
448
  with gr.Row():
449
  with gr.Column(scale=1):
@@ -452,4 +451,17 @@ with gr.Blocks(title="Flux", css=css) as demo:
452
  with gr.Accordion("Mistral API Key (optional)", open=False):
453
  api_key = gr.Textbox(label="API Key", type="password", max_lines=1)
454
  submit = gr.Button("Submit")
455
- preview_image = gr.Image(label="Preview image", type="pil", visible
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  except Exception:
444
  return None, None, "Preview failed"
445
 
 
446
  with gr.Blocks(title="Flux", css=css) as demo:
447
  with gr.Row():
448
  with gr.Column(scale=1):
 
451
  with gr.Accordion("Mistral API Key (optional)", open=False):
452
  api_key = gr.Textbox(label="API Key", type="password", max_lines=1)
453
  submit = gr.Button("Submit")
454
+ preview_image = gr.Image(label="Preview", type="pil", elem_classes="preview_media")
455
+ preview_video = gr.Video(label="Preview", elem_classes="preview_media")
456
+
457
+ with gr.Column(scale=2):
458
+ final_text = gr.Markdown(value="")
459
+
460
+ # Ensure preview outputs get None when not applicable so Gradio hides them
461
+ url_input.change(fn=load_preview, inputs=[url_input], outputs=[preview_image, preview_video, gr.Textbox(visible=False)])
462
+ submit.click(fn=generate_final_text, inputs=[url_input, custom_prompt, api_key], outputs=[final_text])
463
+ demo.queue()
464
+
465
+ if __name__ == "__main__":
466
+ demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
467
+