File size: 475 Bytes
e0f5cfa
 
 
 
 
 
 
 
 
 
37ca165
7e92753
e0f5cfa
 
7e92753
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
import transformers
from transformers import pipeline

p = pipeline("text-generation", "EleutherAI/gpt-neo-1.3B")

im2caption = gr.Interface.load("spaces/akhaliq/CLIP_prefix_captioning")

def im2story(img):
    caption = im2caption(img, "COCO")
    caption = caption[0].lower() + caption[1:]
    story = p("Let me tell you a story about " + caption)[0]["generated_text"]
    return story

gr.Interface(im2story, gr.Image(type="filepath"), "text").launch()