Spaces:
Sleeping
Sleeping
File size: 1,001 Bytes
2f92278 8ee981b 606d19f 8ee981b 606d19f ef7efe9 606d19f 8ee981b 606d19f fb79e86 606d19f ef7efe9 fb79e86 ef7efe9 8ee981b fb79e86 8ee981b 7e16940 |
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 |
import gradio as gr
from gradio_webrtc import WebRTC
# WebRTC 配置
rtc_configuration = {
"iceServers": [{"urls": "stun:stun.l.google.com:19302"}],
"iceTransportPolicy": "relay"
}
# Gradio 界面
css = """.my-group {max-width: 600px !important; max-height: 600 !important;}
.my-column {display: flex !important; justify-content: center !important; align-items: center !important;}"""
with gr.Blocks(css=css) as demo:
gr.HTML(
"""
<h1 style='text-align: center'>
WebRTC Stream Test
</h1>
"""
)
gr.HTML(
"""
<h3 style='text-align: center'>
WebRTC without MediaPipe
</h3>
"""
)
with gr.Column(elem_classes=["my-column"]):
with gr.Group(elem_classes=["my-group"]):
image = WebRTC(label="Stream", rtc_configuration=rtc_configuration)
image.stream(fn=lambda x: x, inputs=[image], outputs=[image], time_limit=10)
if __name__ == "__main__":
demo.launch() |