# app.py import gradio as gr import importlib def load_model(model_name): module = importlib.import_module(model_name) return module app = gr.Blocks() with app: gr.Markdown("## Object Detection using TensorFlow Lite Models") with gr.Row(): model_choice = gr.Dropdown(label="Select Model", choices=["model_1", "model_2", "model_3"]) image_input = gr.Image(type="pil", label="Upload an image") image_output = gr.Image(type="pil", label="Detection Result") video_input = gr.Video(label="Upload a video") video_output = gr.Video(label="Detection Result") def image_detection(model_name, input_image): model = load_model(model_name) return model.detect_image(input_image) def video_detection(model_name, input_video): model = load_model(model_name) return model.detect_video(input_video) gr.Button("Submit Image").click(fn=image_detection, inputs=[model_choice, image_input], outputs=image_output) gr.Button("Submit Video").click(fn=video_detection, inputs=[model_choice, video_input], outputs=video_output) app.launch()