Update app.py
Browse files
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 |
-
#
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
)
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
# Launch the interface
|
104 |
-
|
|
|
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)
|