jyothsnasmohan commited on
Commit
783df1d
·
verified ·
1 Parent(s): 0f63e98

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !pip install transformers
2
+ !pip install gradio
3
+ !pip install gradio_client
4
+ pip install -U gradio_client
5
+ from transformers.utils import logging
6
+ logging.set_verbosity_error()
7
+
8
+ import warnings
9
+ warnings.filterwarnings("ignore",
10
+ message="Using the model-agnostic default `max_length`")
11
+ import os
12
+ import gradio as gr
13
+ from transformers import pipeline
14
+ pipe = pipeline("image-to-text",
15
+ model="Salesforce/blip-image-captioning-base")
16
+ def launch(input):
17
+ out = pipe(input)
18
+ return out[0]['generated_text']
19
+ iface = gr.Interface(launch,
20
+ inputs=gr.Image(type='pil'),
21
+ outputs="text")
22
+ iface.launch()