Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from helper import load_image_from_url, render_results_in_image
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
from transformers.utils import logging
|
5 |
+
logging.set_verbosity_error()
|
6 |
+
|
7 |
+
from helper import ignore_warnings
|
8 |
+
ignore_warnings()
|
9 |
+
|
10 |
+
od_pipe = pipeline("object-detection", "facebook/detr-resnet-50")
|
11 |
+
|
12 |
+
from PIL import Image
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
import os
|
18 |
+
import gradio as gr
|
19 |
+
|
20 |
+
def get_pipeline_prediction(pil_image):
|
21 |
+
|
22 |
+
pipeline_output = od_pipe(pil_image)
|
23 |
+
processed_image = render_results_in_image(pil_image, pipeline_output)
|
24 |
+
return processed_image
|
25 |
+
|
26 |
+
|
27 |
+
demo = gr.Interface(
|
28 |
+
fn=get_pipeline_prediction,
|
29 |
+
inputs=gr.Image(label="Input image",
|
30 |
+
type="pil"),
|
31 |
+
outputs=gr.Image(label="Output image with predicted instances",
|
32 |
+
type="pil")
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
demo.launch(share=True)
|