import gradio as gr from funcs.processor import process_data from funcs.plot_func import plot_sensor_data_from_json with gr.Blocks(title='Cabasus') as cabasus_sensor: title = gr.Markdown("

Data gathering and processing

") with gr.Tab("Convert"): csv_file_box = gr.File(label='Upload CSV File') with gr.Row(): processed_file_box = gr.File(label='Processed CSV File') json_file_box = gr.File(label='Generated Json file') with gr.Row(): slice_size_slider = gr.inputs.Slider(16, 512, 1, 64, label="Slice Size") sample_rate = gr.inputs.Slider(1, 199, 1, 20, label="Sample rate") with gr.Row(): window_size_slider = gr.inputs.Slider(0, 100, 2, 10, label="Window Size") repeat_process = gr.Button('Restart process') with gr.Row(): leg_dropdown = gr.Dropdown(choices=['GZ1', 'GZ2', 'GZ3', 'GZ4'], label='select leg', value='GZ1') slice_slider = gr.Slider(minimum=1, maximum=300, label='Current slice', step=1) with gr.Row(): plot_box_leg = gr.Plot(label="Filtered Signal Plot") plot_box_overlay = gr.Plot(label="Overlay Signal Plot") with gr.Row(): plot_slice_leg = gr.Plot(label="Sliced Signal Plot") get_all_slice = gr.Plot(label="Real Signal Plot") with gr.Row(): animation = gr.PlayableVideo(label="Animated horse steps") slices_per_leg = gr.Textbox(label="Number of slices found per LEG") csv_file_box.change(process_data, inputs=[csv_file_box, slice_size_slider, sample_rate, window_size_slider], outputs=[processed_file_box, json_file_box, slices_per_leg, plot_box_leg, plot_box_overlay, slice_slider, plot_slice_leg, get_all_slice]) leg_dropdown.change(plot_sensor_data_from_json, inputs=[json_file_box, leg_dropdown, slice_slider], outputs=[plot_box_leg, plot_slice_leg, get_all_slice]) repeat_process.click(process_data, inputs=[csv_file_box, slice_size_slider, sample_rate, window_size_slider], outputs=[processed_file_box, json_file_box, slices_per_leg, plot_box_leg, plot_box_overlay, slice_slider, plot_slice_leg, get_all_slice]) slice_slider.change(plot_sensor_data_from_json, inputs=[json_file_box, leg_dropdown, slice_slider], outputs=[plot_box_leg, plot_slice_leg, get_all_slice]) cabasus_sensor.queue(concurrency_count=2).launch(debug=True)