Ashish Soni commited on
Commit
6d66457
·
1 Parent(s): 85d59f3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")
5
+
6
+ def summarize(input):
7
+ output = get_completion(input)
8
+ return output[0]['generated_text']
9
+
10
+ gr.close_all()
11
+ demo = gr.Interface(fn=captioner,
12
+ inputs=[gr.Image(label="Upload image", type="pil")],
13
+ outputs=[gr.Textbox(label="Caption")],
14
+ title="Image Captioning with BLIP",
15
+ description="Caption any image using the BLIP model",
16
+ allow_flagging="never",
17
+ examples=["christmas_dog.jpeg", "bird_flight.jpeg", "cow.jpeg"])
18
+
19
+ demo.launch()