Spaces:
Runtime error
Runtime error
File size: 1,331 Bytes
fc286f6 |
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 |
import gradio as gr
from app.app_utils import preprocess_video_and_predict_sleep_quality
def clear_sleep_quality_info():
return [gr.Video(value=None)] * 3 + [gr.Image(value=None), gr.Plot(value=None)]
def create_sleep_quality_tab():
with gr.Row():
with gr.Column(scale=1):
input_video = gr.Video(elem_classes="video1")
with gr.Row():
clear_btn = gr.Button("Clear")
submit_btn = gr.Button("Analyze", elem_classes="submit")
with gr.Column(scale=1, elem_classes="dl4"):
outputs = [
gr.Video(label=label, elem_classes=f"video{i+2}")
for i, label in enumerate(["Original video", "Pre-processed video", "Sleep quality analysis"])
]
outputs.extend([
gr.Image(label="Eye bags detection", elem_classes="eyebags"),
gr.Plot(label="Sleep quality indicators", elem_classes="stat")
])
submit_btn.click(
fn=preprocess_video_and_predict_sleep_quality,
inputs=input_video,
outputs=outputs,
queue=True,
)
clear_btn.click(
fn=clear_sleep_quality_info,
outputs=[input_video] + outputs,
queue=True,
)
gr.Examples(["./assets/videos/fitness.mp4"], inputs=[input_video]) |