Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,21 +10,22 @@ def launch(input):
|
|
| 10 |
out = pipe(input) # Get the model output
|
| 11 |
return out[0]['generated_text'] # Return the generated text
|
| 12 |
|
| 13 |
-
# Define examples
|
| 14 |
examples = [
|
| 15 |
-
["example1.jpg","a dog swimming in the ocean"], #
|
| 16 |
-
["example2.png","a fairy
|
| 17 |
]
|
| 18 |
|
| 19 |
# Create the Gradio interface
|
| 20 |
iface = gr.Interface(
|
| 21 |
-
launch,
|
| 22 |
inputs=gr.Image(type='pil'), # Input is an image
|
| 23 |
outputs="text", # Output is a text description
|
| 24 |
title="Image Captioning with BLIP",
|
| 25 |
description="This application uses the BLIP image-captioning model to generate descriptions for the images you upload. "
|
| 26 |
-
"Simply upload an image, and the model will generate a caption describing the content of the image."
|
| 27 |
-
|
|
|
|
| 28 |
)
|
| 29 |
|
| 30 |
# Launch the interface
|
|
|
|
| 10 |
out = pipe(input) # Get the model output
|
| 11 |
return out[0]['generated_text'] # Return the generated text
|
| 12 |
|
| 13 |
+
# Define examples with images and expected outputs
|
| 14 |
examples = [
|
| 15 |
+
["example1.jpg", "a dog swimming in the ocean"], # Example 1
|
| 16 |
+
["example2.png", "a fairy sitting on a tree branch"] # Example 2
|
| 17 |
]
|
| 18 |
|
| 19 |
# Create the Gradio interface
|
| 20 |
iface = gr.Interface(
|
| 21 |
+
fn=launch,
|
| 22 |
inputs=gr.Image(type='pil'), # Input is an image
|
| 23 |
outputs="text", # Output is a text description
|
| 24 |
title="Image Captioning with BLIP",
|
| 25 |
description="This application uses the BLIP image-captioning model to generate descriptions for the images you upload. "
|
| 26 |
+
"Simply upload an image, and the model will generate a caption describing the content of the image. "
|
| 27 |
+
"You can also try some pre-loaded examples below.",
|
| 28 |
+
examples=[example[:1] for example in examples] # Only include image paths for Gradio
|
| 29 |
)
|
| 30 |
|
| 31 |
# Launch the interface
|