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