Spaces:
Sleeping
Sleeping
updated
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import pipeline
|
| 4 |
import torch
|
|
@@ -19,17 +18,14 @@ def generate_caption(image):
|
|
| 19 |
except Exception as e:
|
| 20 |
return f"Error generating caption: {str(e)}"
|
| 21 |
|
| 22 |
-
# Create Gradio interface
|
| 23 |
interface = gr.Interface(
|
| 24 |
fn=generate_caption,
|
| 25 |
inputs=gr.Image(type="pil"),
|
| 26 |
outputs=gr.Textbox(label="Generated Caption"),
|
| 27 |
title="Image Caption Generator",
|
| 28 |
description="Upload an image and get an AI-generated caption!",
|
| 29 |
-
|
| 30 |
-
["https://raw.githubusercontent.com/gradio-app/gradio/main/demo/kitchen.jpg"],
|
| 31 |
-
],
|
| 32 |
-
cache_examples=True
|
| 33 |
)
|
| 34 |
|
| 35 |
# Launch the app
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
import torch
|
|
|
|
| 18 |
except Exception as e:
|
| 19 |
return f"Error generating caption: {str(e)}"
|
| 20 |
|
| 21 |
+
# Create Gradio interface without examples
|
| 22 |
interface = gr.Interface(
|
| 23 |
fn=generate_caption,
|
| 24 |
inputs=gr.Image(type="pil"),
|
| 25 |
outputs=gr.Textbox(label="Generated Caption"),
|
| 26 |
title="Image Caption Generator",
|
| 27 |
description="Upload an image and get an AI-generated caption!",
|
| 28 |
+
article="Built using the BLIP image captioning model from Salesforce."
|
|
|
|
|
|
|
|
|
|
| 29 |
)
|
| 30 |
|
| 31 |
# Launch the app
|