Spaces:
Sleeping
Sleeping
| import numpy as np | |
| import gradio as gr | |
| from detection import detect_objects | |
| from config import PASCAL_CLASSES | |
| def inference( | |
| image: np.ndarray, | |
| iou_thresh: float, thresh: float, | |
| enable_grad_cam: str, | |
| transparency: float, | |
| ): | |
| infer_output = detect_objects(image, iou_thresh, thresh, enable_grad_cam, transparency) | |
| return infer_output | |
| title = "YoloV3 for Pascal VOC Dataset" | |
| description = f"Pytorch Implementation of YoloV3 model trained on Pascal VOC dataset with GradCAM \n Classes in pascol voc are: {', '.join(PASCAL_CLASSES)}" | |
| example_images = [ | |
| ["images/001114.jpg", 0.7, 0.5, True, 0.6], | |
| ["images/001133.jpg", 0.6, 0.5, True, 0.6], | |
| ["images/001142.jpg", 0.65, 0.45, True, 0.6], | |
| ["images/001147.jpg", 0.6, 0.5, True, 0.6], | |
| ["images/001155.jpg", 0.7, 0.7, True, 0.6], | |
| ] | |
| demo = gr.Interface( | |
| inference, | |
| inputs=[ | |
| gr.Image(label="Input Image"), | |
| gr.Slider(0, 1, value=0.5, label="IOU Threshold"), | |
| gr.Slider(0, 1, value=0.4, label="Threshold"), | |
| gr.Checkbox(label="Show Grad Cam"), | |
| gr.Slider(0, 1, value=0.5, label="Opacity of GradCAM"), | |
| ], | |
| outputs=[ | |
| gr.Gallery(rows=2, columns=1), | |
| ], | |
| title=title, | |
| description=description, | |
| examples=example_images, | |
| ) | |
| demo.launch(debug=True) |