eskayML commited on
Commit
ffe7bc8
1 Parent(s): 8bd28b4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ image_to_text = pipeline("image-to-text", model="nlpconnect/vit-gpt2-image-captioning")
5
+
6
+
7
+ def generate_caption(img):
8
+ caption = image_to_text(img)
9
+ return caption[0]['generated_text']
10
+
11
+
12
+ demo = gr.Interface(
13
+ fn = generate_caption,
14
+ inputs = gr.Image(type = 'filepath'),
15
+ outputs = gr.Textbox(lines = 2),
16
+ )
17
+ demo.launch()