Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import transformers
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
p = pipeline("text-generation", "EleutherAI/gpt-neo-1.3B")
|
6 |
+
|
7 |
+
im2caption = gr.Interface.load("spaces/akhaliq/CLIP_prefix_captioning")
|
8 |
+
|
9 |
+
def im2story(img):
|
10 |
+
caption = im2caption(img, "COCO")
|
11 |
+
if caption[-1] == ".":
|
12 |
+
caption = caption[:-1]
|
13 |
+
story = p(caption)[0]["generated_text"]
|
14 |
+
return story
|
15 |
+
|
16 |
+
gr.Interface(im2story, gr.Image(type="filepath"), "text", title="Image 2 Story").launch()
|