Commit
•
6b07f33
1
Parent(s):
04801b0
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
from helper import load_image_from_url, render_results_in_image
|
5 |
+
|
6 |
+
|
7 |
+
def get_pipeline_prediction(pil_image):
|
8 |
+
|
9 |
+
od_pipe = pipeline("object-detection", "facebook/detr-resnet-50")
|
10 |
+
|
11 |
+
pipeline_output = od_pipe(pil_image)
|
12 |
+
|
13 |
+
processed_image = render_results_in_image(pil_image,
|
14 |
+
pipeline_output)
|
15 |
+
return processed_image
|
16 |
+
|
17 |
+
|
18 |
+
gr.Interface(
|
19 |
+
fn=get_pipeline_prediction,
|
20 |
+
inputs=gr.Image(label="Input image",
|
21 |
+
type="pil"),
|
22 |
+
outputs=gr.Image(label="Output image with predicted instances",
|
23 |
+
type="pil")
|
24 |
+
)
|