Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from helper import load_image_from_url, render_results_in_image
|
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 |
+
from helper import ignore_warnings
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
od_pipe = pipeline("object-detection", "./models/facebook/detr-resnet-50")
|
12 |
+
|
13 |
+
def get_pipeline_prediction(pil_image):
|
14 |
+
|
15 |
+
pipeline_output = od_pipe(pil_image)
|
16 |
+
|
17 |
+
processed_image = render_results_in_image(pil_image,
|
18 |
+
pipeline_output)
|
19 |
+
return processed_image
|
20 |
+
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=get_pipeline_prediction,
|
23 |
+
inputs=gr.Image(label="Input image",
|
24 |
+
type="pil"),
|
25 |
+
outputs=gr.Image(label="Output image with predicted instances",
|
26 |
+
type="pil")
|
27 |
+
)
|
28 |
+
|
29 |
+
demo.launch(share=False)
|