Spaces:
Sleeping
Sleeping
Added requirements and Application file. Initial version.
Browse files- app.py +22 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
|
6 |
+
pipe = pipeline("image-to-text",
|
7 |
+
model="Salesforce/blip-image-captioning-base")
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
def launch(input):
|
12 |
+
out = pipe(input)
|
13 |
+
return out[0]['generated_text']
|
14 |
+
|
15 |
+
|
16 |
+
iface = gr.Interface(fn=launch,
|
17 |
+
inputs=gr.Image(type='pil'),
|
18 |
+
outputs="text")
|
19 |
+
|
20 |
+
iface.launch(share=False)
|
21 |
+
|
22 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|
4 |
+
|