Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Image to text function
|
6 |
+
def image2text(image_path):
|
7 |
+
captioner = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
|
8 |
+
text = captioner(image_path)[0]['generated_text']
|
9 |
+
return text
|
10 |
+
|
11 |
+
|
12 |
+
# Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn= image2text,
|
15 |
+
inputs=[
|
16 |
+
gr.Image(type="filepath", label="Upload Image"),
|
17 |
+
|
18 |
+
],
|
19 |
+
outputs="text",
|
20 |
+
title="Image Description Generator",
|
21 |
+
description="Upload an image and get a generated description."
|
22 |
+
)
|
23 |
+
|
24 |
+
|
25 |
+
iface.launch(inline = False)
|
26 |
+
|