abhi227070 commited on
Commit
33a6854
·
verified ·
1 Parent(s): 77a091d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from PIL import Image
3
+ import gradio as gr
4
+
5
+ model = None
6
+
7
+ if model == None:
8
+ model = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large")
9
+
10
+ def captioner(image):
11
+
12
+ img = Image.fromarray(image)
13
+ result = model(img)[0]['generated_text']
14
+ return result
15
+
16
+ iface = gr.Interface(
17
+ fn = captioner,
18
+ inputs = gr.Image(),
19
+ outputs = 'text'
20
+ )
21
+
22
+ iface.launch()