Download app.py from brainai-projects/object_detection_Gradio: direct link, hf CLI and curl.
- Browser
- Download file 846 Bytes
-
https://huggingface.co/spaces/brainai-projects/object_detection_Gradio/resolve/main/app.py
- Command line
-
hf download hf://spaces/brainai-projects/object_detection_Gradio/app.py
-
curl -L -o app.py https://huggingface.co/spaces/brainai-projects/object_detection_Gradio/resolve/main/app.py
846 Bytes
| import gradio as gr | |
| from utils import object_detection_brainai as odb | |
| object_detection = odb.ObjectDetectionModel() | |
| def detect_image(img): | |
| result_img = object_detection.process(img) | |
| return result_img | |
| def detect_video(video_path): | |
| output_video_path = object_detection.play_video(video_path) | |
| return output_video_path | |
| image_interface = gr.Interface( | |
| fn=detect_image, | |
| title="Image Object Detection", | |
| inputs=gr.Image(label="Upload Image"), | |
| outputs="image", | |
| examples = ['data/office.jpg', 'data/classroom.jpg']) | |
| video_interface = gr.Interface( | |
| fn=detect_video, | |
| inputs=gr.Video(label="Upload Video"), | |
| examples = ['data/breakfast-example.mp4'], | |
| outputs="video", | |
| title="Video Object Detection") | |
| demo = gr.TabbedInterface([image_interface, video_interface], ["Image", "Video"]) | |
| demo.launch() | |