Spaces:
Sleeping
Sleeping
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
|
6 |
def generate_caption(image):
|
7 |
-
result =
|
8 |
return result[0]["generated_text"].strip()
|
9 |
|
10 |
title = "🖼️ Image Caption Generator"
|
@@ -16,7 +16,7 @@ demo = gr.Interface(
|
|
16 |
outputs=gr.Textbox(label="Generated Caption"),
|
17 |
title=title,
|
18 |
description=description,
|
19 |
-
|
20 |
)
|
21 |
|
22 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
pipe = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
|
5 |
|
6 |
def generate_caption(image):
|
7 |
+
result = pipe(image)
|
8 |
return result[0]["generated_text"].strip()
|
9 |
|
10 |
title = "🖼️ Image Caption Generator"
|
|
|
16 |
outputs=gr.Textbox(label="Generated Caption"),
|
17 |
title=title,
|
18 |
description=description,
|
19 |
+
flagging_mode="never"
|
20 |
)
|
21 |
|
22 |
if __name__ == "__main__":
|