test / app.py
liuhui0401's picture
Update app.py
fb79e86 verified
raw
history blame
1 kB
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()