File size: 1,269 Bytes
ab8fcc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
import numpy as np
import gradio as gr
from detect import predict

from config import PASCAL_CLASSES


def inference(
    org_img: np.ndarray,
    iou_thresh: float, thresh: float,
    show_cam: str,
    transparency: float,
):
    outputs = predict(org_img, iou_thresh, thresh, show_cam, transparency)
    return outputs



title = "YoloV3 from Scratch on Pascal VOC Dataset with GradCAM"
description = f"Pytorch Implemetation of YoloV3 trained from scratch on Pascal VOC dataset with GradCAM \n Class in pascol voc: {', '.join(PASCAL_CLASSES)}"
examples = [
    ["images/000014.jpg", 0.5, 0.4, True, 0.5],
    ["images/000017.jpg", 0.6, 0.5, True, 0.5],
    ["images/000018.jpg", 0.55, 0.45, True, 0.5],
    ["images/000030.jpg", 0.5, 0.4, True, 0.5],
    ["images/Puppies.jpg", 0.6, 0.7, True, 0.5],
]

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=examples,
)
demo.launch()