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