jyothsnasmohan commited on
Commit
d40d646
·
verified ·
1 Parent(s): 943f6e5

Create caption.py

Browse files
Files changed (1) hide show
  1. caption.py +13 -0
caption.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipe = pipeline("image-to-text", model="salesforce/blip-image-captioning-base")
5
+
6
+ def launch(input):
7
+ out = pipe(input)
8
+ return out[0]['generated_text']
9
+
10
+ iface = gr.Interface(launch,
11
+ inputs=gr.inputs.Image(type='pil'),
12
+ outputs="text")
13
+ iface.launch(share=True)