EthanStanks's picture
Fixing file upload
8d70ec1
import gradio as gr
import app_backend
gr.set_static_paths(['.'])
def detect_crashes(name, sim_files, real_files, frame_out, text_output, file_out, video_out):
for outputs in app_backend.backend(name, sim_files, real_files, frame_out, text_output, file_out, video_out):
yield outputs
with gr.Blocks(title="Drone Crash Detection") as demo:
text_output = gr.Textbox(interactive=False)
frame_output = gr.Image(interactive=False)
video_output = gr.Gallery(interactive=False)
file_output = gr.File(interactive=False)
label = gr.Label("Drone Crash Classification Using Yolov8.", scale=0, show_label=False)
student_name_tb = gr.Textbox(
lines=1,
placeholder="Enter student's name. Ex: 'First Last'",
visible=True,
show_label=True,
label="Student's Name"
)
simulation_videos_upload = gr.File(
label="Upload Simulation Drone Videos",
type="filepath", # Changed 'file' to 'filepath'
file_count="multiple"
)
real_videos_upload = gr.File(
label="Upload Real Drone Videos",
type="filepath", # Changed 'file' to 'filepath'
file_count="multiple"
)
with gr.Row():
btn_prompt = gr.Button("Detect Crashes")
btn_prompt.click(
fn=detect_crashes,
inputs=[
student_name_tb,
simulation_videos_upload,
real_videos_upload,
frame_output,
text_output,
file_output,
video_output
],
outputs=[frame_output, text_output, file_output, video_output]
)
demo.launch()