Spaces:
Sleeping
Sleeping
GlenJay2004
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Filter the warnings
|
2 |
+
import warnings
|
3 |
+
warnings.filterwarnings('ignore')
|
4 |
+
from transformers import logging
|
5 |
+
logging.set_verbosity_error()
|
6 |
+
|
7 |
+
#Import the necessary
|
8 |
+
import gradio as gr
|
9 |
+
from transformers import pipeline
|
10 |
+
|
11 |
+
#Perform Image Captioning
|
12 |
+
get_completion = pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")
|
13 |
+
|
14 |
+
#Launch the input
|
15 |
+
def launch(input):
|
16 |
+
out=get_completion(input)
|
17 |
+
return out[0]['generated_text']
|
18 |
+
|
19 |
+
#Define an interface
|
20 |
+
interface=gr.Interface(fn=launch,inputs=gr.Image(type="pil"),outputs="text",title="Image Captioning with BLIP")
|
21 |
+
|
22 |
+
interface.launch()
|
23 |
+
|