Spaces:
Sleeping
Sleeping
Jasmeet Singh
commited on
gradio-application
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
model_pipeline = pipeline("image-to-text",
|
| 5 |
+
model = "Salesforce/blip-image-captioning-base")
|
| 6 |
+
#990M model
|
| 7 |
+
|
| 8 |
+
def main(input):
|
| 9 |
+
output = model_pipeline(input) #globally defined model pipeline
|
| 10 |
+
return output[0]['generated_text'] #generated output captoion string
|
| 11 |
+
|
| 12 |
+
interface_gradio = gr.Interface(
|
| 13 |
+
main,
|
| 14 |
+
inputs = gr.Image(type = 'pil'),
|
| 15 |
+
outputs = "text"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
interface_gradio.launch()
|