Spaces:
Sleeping
Sleeping
File size: 1,299 Bytes
5c5fbf4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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) |