Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
od_pipe = pipeline("object-detection", "facebook/detr-resnet-50")
|
| 7 |
+
|
| 8 |
+
def get_pipeline_prediction(pil_image):
|
| 9 |
+
pipeline_output = od_pipe(pil_image)
|
| 10 |
+
processed_image = render_results_in_image(pil_image, pipeline_output)
|
| 11 |
+
return processed_image
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
fn = get_pipeline_prediction,
|
| 15 |
+
inputs = gr.Image(label="Input image", type="pil"),
|
| 16 |
+
outputs = gr.Image(label="Output image with predicted instances", type="pil")
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
demo.launch(enable_queue=True, debug=True)
|