Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_webrtc import WebRTC
|
|
|
|
|
|
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
with gr.Blocks() as demo:
|
| 6 |
-
image = WebRTC(label="Stream", mode="
|
| 7 |
conf_threshold = gr.Slider(
|
| 8 |
label="Confidence Threshold",
|
| 9 |
minimum=0.0,
|
|
@@ -11,10 +21,33 @@ with gr.Blocks() as demo:
|
|
| 11 |
step=0.05,
|
| 12 |
value=0.30,
|
| 13 |
)
|
|
|
|
| 14 |
image.stream(
|
| 15 |
-
|
| 16 |
-
|
| 17 |
)
|
|
|
|
|
|
|
| 18 |
|
| 19 |
if __name__ == "__main__":
|
| 20 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_webrtc import WebRTC
|
| 3 |
+
import cv2
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
+
def generation():
|
| 7 |
+
url = 0
|
| 8 |
+
cap = cv2.VideoCapture(url)
|
| 9 |
+
iterating = True
|
| 10 |
+
while iterating:
|
| 11 |
+
iterating, frame = cap.read()
|
| 12 |
+
frame=cv2.flip(frame,1)
|
| 13 |
+
yield frame
|
| 14 |
|
| 15 |
with gr.Blocks() as demo:
|
| 16 |
+
image = WebRTC(label="Stream", mode="receive", modality="video", height=480, width=640)
|
| 17 |
conf_threshold = gr.Slider(
|
| 18 |
label="Confidence Threshold",
|
| 19 |
minimum=0.0,
|
|
|
|
| 21 |
step=0.05,
|
| 22 |
value=0.30,
|
| 23 |
)
|
| 24 |
+
button = gr.Button("Start", variant="primary")
|
| 25 |
image.stream(
|
| 26 |
+
fn=generation, inputs=None, outputs=[image],
|
| 27 |
+
trigger=button.click
|
| 28 |
)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
+
demo.launch()
|
| 34 |
+
# import gradio as gr
|
| 35 |
+
# from gradio_webrtc import WebRTC
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# with gr.Blocks() as demo:
|
| 39 |
+
# image = WebRTC(label="Stream", mode="send-receive", modality="video")
|
| 40 |
+
# conf_threshold = gr.Slider(
|
| 41 |
+
# label="Confidence Threshold",
|
| 42 |
+
# minimum=0.0,
|
| 43 |
+
# maximum=1.0,
|
| 44 |
+
# step=0.05,
|
| 45 |
+
# value=0.30,
|
| 46 |
+
# )
|
| 47 |
+
# image.stream(
|
| 48 |
+
# inputs=[image, conf_threshold],
|
| 49 |
+
# outputs=[image], time_limit=10
|
| 50 |
+
# )
|
| 51 |
+
|
| 52 |
+
# if __name__ == "__main__":
|
| 53 |
+
# demo.launch()
|