Spaces:
Sleeping
Sleeping
Upload application file
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import gradio as gr
|
3 |
+
from detection import detect_objects
|
4 |
+
from config import PASCAL_CLASSES
|
5 |
+
|
6 |
+
|
7 |
+
def inference(
|
8 |
+
image: np.ndarray,
|
9 |
+
iou_thresh: float, thresh: float,
|
10 |
+
enable_grad_cam: str,
|
11 |
+
transparency: float,
|
12 |
+
):
|
13 |
+
infer_output = detect_objects(image, iou_thresh, thresh, enable_grad_cam, transparency)
|
14 |
+
return infer_output
|
15 |
+
|
16 |
+
|
17 |
+
title = "YoloV3 for Pascal VOC Dataset"
|
18 |
+
description = f"Pytorch Implementation of YoloV3 model trained on Pascal VOC dataset with GradCAM \n Classes in pascol voc are: {', '.join(PASCAL_CLASSES)}"
|
19 |
+
example_images = [
|
20 |
+
["images/001114.jpg", 0.7, 0.5, True, 0.6],
|
21 |
+
["images/001133.jpg", 0.6, 0.5, True, 0.6],
|
22 |
+
["images/001142.jpg", 0.65, 0.45, True, 0.6],
|
23 |
+
["images/001147.jpg", 0.6, 0.5, True, 0.6],
|
24 |
+
["images/001155.jpg", 0.7, 0.7, True, 0.6],
|
25 |
+
]
|
26 |
+
|
27 |
+
demo = gr.Interface(
|
28 |
+
inference,
|
29 |
+
inputs=[
|
30 |
+
gr.Image(label="Input Image"),
|
31 |
+
gr.Slider(0, 1, value=0.5, label="IOU Threshold"),
|
32 |
+
gr.Slider(0, 1, value=0.4, label="Threshold"),
|
33 |
+
gr.Checkbox(label="Show Grad Cam"),
|
34 |
+
gr.Slider(0, 1, value=0.5, label="Opacity of GradCAM"),
|
35 |
+
],
|
36 |
+
outputs=[
|
37 |
+
gr.Gallery(rows=2, columns=1),
|
38 |
+
],
|
39 |
+
title=title,
|
40 |
+
description=description,
|
41 |
+
examples=example_images,
|
42 |
+
)
|
43 |
+
|
44 |
+
demo.launch(debug=True)
|