prithivMLmods commited on
Commit
a5b1435
·
verified ·
1 Parent(s): bab496f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -87,18 +87,23 @@ description = "Select the model to use for generating the image description. 'Ba
87
  if device == "cpu":
88
  description += " Note: Running on CPU, which may be slow for large models."
89
 
90
- # Create the Gradio interface
91
- image_description_interface = gr.Interface(
92
- fn=describe_image,
93
- inputs=[
94
- gr.Image(label="Upload Image", type="pil"),
95
- gr.Radio(["Base", "Large"], label="Model Choice", value="Base")
96
- ],
97
- outputs=gr.Textbox(label="Generated Caption", lines=4, show_copy_button=True),
98
- live=False,
99
- title="Florence-2 Models Image Captions",
100
- description=description
101
- )
 
 
 
 
 
102
 
103
  # Launch the interface
104
- image_description_interface.launch(debug=True)
 
87
  if device == "cpu":
88
  description += " Note: Running on CPU, which may be slow for large models."
89
 
90
+ # Define examples
91
+ examples = [
92
+ ["images/1.png", "Base"],
93
+ ["images/1.png", "Large"]
94
+ ]
95
+
96
+ # Create the Gradio interface with Blocks
97
+ with gr.Blocks(theme="bethecloud/storj_theme") as demo:
98
+ gr.Markdown("# **Florence-2 Models Image Captions**")
99
+ gr.Markdown(description)
100
+ with gr.Row():
101
+ image_input = gr.Image(label="Upload Image", type="pil")
102
+ model_choice = gr.Radio(["Base", "Large"], label="Model Choice", value="Base")
103
+ output = gr.Textbox(label="Generated Caption", lines=4, show_copy_button=True)
104
+ generate_btn = gr.Button("Generate Caption")
105
+ generate_btn.click(fn=describe_image, inputs=[image_input, model_choice], outputs=output)
106
+ gr.Examples(examples=examples, inputs=[image_input, model_choice])
107
 
108
  # Launch the interface
109
+ demo.launch(debug=True)