MSaadTariq commited on
Commit
e4c1abf
·
verified ·
1 Parent(s): c6e4344

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from helper import load_image_from_url, render_results_in_image
3
+
4
+ od_pipe = pipeline("object-detection", "facebook/detr-resnet-50")
5
+
6
+ import gradio as gr
7
+
8
+ def get_pipeline_prediction(pil_image):
9
+ #first get the pipeline output given the pil image
10
+ pipeline_output = od_pipe(pil_image)
11
+
12
+ #then process the image using the pipeline output
13
+ processed_image = render_results_in_image(pil_image, pipeline_output)
14
+ return processed_image
15
+
16
+ demo = gr.Interface(
17
+ fn= get_pipeline_prediction,
18
+ inputs=gr.Image(label="Input Image",
19
+ type="pil"),
20
+ outputs=gr.Image(label="Output Image with predictions",
21
+ type="pil"),
22
+ title="Object Detection API",
23
+ description="Just upload your image and let ObjectDetect API work its magic, revealing the objects waiting to be discovered"
24
+ )
25
+ demo.launch()