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