Spaces:
Sleeping
Sleeping
Commit
•
66947f7
1
Parent(s):
ccc35d4
code
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ def draw_bounding_boxes(image, results, model, threshold=0.3):
|
|
21 |
|
22 |
|
23 |
@spaces.GPU
|
24 |
-
def
|
25 |
|
26 |
inputs = image_processor(images=image, return_tensors="pt")
|
27 |
|
@@ -60,17 +60,31 @@ with gr.Blocks(css=css) as app:
|
|
60 |
gr.HTML(
|
61 |
"""
|
62 |
<h1 style='text-align: center'>
|
63 |
-
Near Real-Time Webcam Stream with
|
64 |
</h1>
|
65 |
""")
|
66 |
gr.HTML(
|
67 |
"""
|
68 |
<h3 style='text-align: center'>
|
69 |
-
<a href='https://arxiv.org/abs/2304.08069' target='_blank'>arXiv</a> | <a href='https://github.com/
|
70 |
</h3>
|
71 |
""")
|
72 |
-
with gr.
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
if __name__ == '__main__':
|
76 |
app.launch()
|
|
|
21 |
|
22 |
|
23 |
@spaces.GPU
|
24 |
+
def inference(image, conf_threshold):
|
25 |
|
26 |
inputs = image_processor(images=image, return_tensors="pt")
|
27 |
|
|
|
60 |
gr.HTML(
|
61 |
"""
|
62 |
<h1 style='text-align: center'>
|
63 |
+
Near Real-Time Webcam Stream with RT-DETR
|
64 |
</h1>
|
65 |
""")
|
66 |
gr.HTML(
|
67 |
"""
|
68 |
<h3 style='text-align: center'>
|
69 |
+
<a href='https://arxiv.org/abs/2304.08069' target='_blank'>arXiv</a> | <a href='https://github.com/lyuwenyu/RT-DETR' target='_blank'>github</a>
|
70 |
</h3>
|
71 |
""")
|
72 |
+
with gr.Column(elem_classes=['my-column']):
|
73 |
+
with gr.Group(elem_classes=["my-group"]):
|
74 |
+
image = gr.Image(type="pil", label="Image", visible=True, sources="webcam", height=500, width=500)
|
75 |
+
conf_threshold = gr.Slider(
|
76 |
+
label="Confidence Threshold",
|
77 |
+
minimum=0.0,
|
78 |
+
maximum=1.0,
|
79 |
+
step=0.05,
|
80 |
+
value=0.85,
|
81 |
+
)
|
82 |
+
image.stream(
|
83 |
+
fn=inference,
|
84 |
+
inputs=[image, conf_threshold],
|
85 |
+
outputs=[image],
|
86 |
+
stream_every=0.2,
|
87 |
+
time_limit=30
|
88 |
+
)
|
89 |
if __name__ == '__main__':
|
90 |
app.launch()
|