Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
from transformers.utils import logging
|
| 4 |
import os
|
| 5 |
-
import gradio as gr
|
| 6 |
-
from PIL import Image
|
| 7 |
-
# Use a pipeline as a high-level helper
|
| 8 |
from transformers import pipeline
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
def get_pipeline_prediction(pil_image):
|
| 16 |
-
|
| 17 |
-
pipeline_output = od_pipe(pil_image)
|
| 18 |
-
|
| 19 |
-
processed_image = render_results_in_image(pil_image,
|
| 20 |
-
pipeline_output)
|
| 21 |
-
return processed_image
|
| 22 |
-
|
| 23 |
-
demo = gr.Interface(
|
| 24 |
-
fn=get_pipeline_prediction,
|
| 25 |
-
inputs=gr.Image(label="Input image",
|
| 26 |
-
type="pil"),
|
| 27 |
-
outputs=gr.Image(label="Output image with predicted instances",
|
| 28 |
-
type="pil")
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
demo.launch(share=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
pipe = pipeline("image-to-text",
|
| 5 |
+
model="./models/Salesforce/blip-image-captioning-base")
|
| 6 |
|
| 7 |
+
def launch(input):
|
| 8 |
+
out = pipe(input)
|
| 9 |
+
return out[0]['generated_text']
|
| 10 |
|
| 11 |
+
app = gr.Interface(launch,
|
| 12 |
+
inputs=gr.Image(type='pil'),
|
| 13 |
+
outputs="text")
|
| 14 |
|
| 15 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|