wgetdd commited on
Commit
cda4e7a
1 Parent(s): 79a9966

Add main app.py file

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ from src.detect import predict
4
+
5
+ from src.config import PASCAL_CLASSES
6
+
7
+
8
+ # def inference(
9
+ # org_img: np.ndarray,
10
+ # iou_thresh: float, thresh: float,
11
+ # show_cam: str,
12
+ # transparency: float,
13
+ # ):
14
+ # outputs = predict(org_img, iou_thresh, thresh, show_cam, transparency)
15
+ # return outputs
16
+
17
+ # demo = gr.Interface(
18
+ # predict,
19
+ # inputs=[
20
+ # gr.Image(label="Input Image"),
21
+ # gr.Slider(0, 1, value=0.5, label="IOU Threshold"),
22
+ # gr.Slider(0, 1, value=0.4, label="Threshold"),
23
+ # gr.Checkbox(label="Show Grad Cam"),
24
+ # gr.Slider(0, 1, value=0.5, label="Opacity of GradCAM"),
25
+ # ],
26
+ # outputs=[
27
+ # gr.Gallery(rows=2, columns=1),
28
+ # ],
29
+ # title="YoloV3 on PASCAL VOC Dataset From Scratch",
30
+ # examples=[
31
+ # ["example_images/009922.jpg", 0.5, 0.4, True, 0.5],
32
+ # ["example_images/009938.jpg", 0.6, 0.5, True, 0.5],
33
+ # ["example_images/009948.jpg", 0.55, 0.45, True, 0.5],
34
+ # ["example_images/009952.jpg", 0.5, 0.4, True, 0.5],
35
+ # ["example_images/009953.jpg", 0.6, 0.7, True, 0.5],
36
+ # ["example_images/009956.jpg", 0.5, 0.4, True, 0.5],
37
+ # ["example_images/009957.jpg", 0.6, 0.5, True, 0.5],
38
+ # ["example_images/009960.jpg", 0.55, 0.45, True, 0.5],
39
+ # ["example_images/009961.jpg", 0.5, 0.4, True, 0.5],
40
+ # ["example_images/009962.jpg", 0.6, 0.7, True, 0.5],
41
+ # ],
42
+ # )
43
+ # demo.launch()
44
+
45
+
46
+ gr.Interface(
47
+ predict,
48
+ inputs=[
49
+ gr.Image(label="Input Image"),
50
+ gr.Slider(0, 1, value=0.5, label="IOU Threshold"),
51
+ gr.Slider(0, 1, value=0.4, label="Threshold"),
52
+ gr.Checkbox(label="Show Grad Cam"),
53
+ gr.Slider(0, 1, value=0.5, label="Opacity of GradCAM"),
54
+ ],
55
+ outputs=gr.Gallery(rows=2, columns=1),
56
+ title="YoloV3 on PASCAL VOC Dataset From Scratch (Slide for GradCam output)",
57
+ examples=[
58
+ ["example_images/009922.jpg", 0.5, 0.4, True, 0.5],
59
+ ["example_images/009938.jpg", 0.6, 0.5, True, 0.5],
60
+ ["example_images/009948.jpg", 0.55, 0.45, True, 0.5],
61
+ ["example_images/009952.jpg", 0.5, 0.4, True, 0.5],
62
+ ["example_images/009953.jpg", 0.6, 0.7, True, 0.5],
63
+ ["example_images/009956.jpg", 0.5, 0.4, True, 0.5],
64
+ ["example_images/009957.jpg", 0.6, 0.5, True, 0.5],
65
+ ["example_images/009960.jpg", 0.55, 0.45, True, 0.5],
66
+ ["example_images/009961.jpg", 0.5, 0.4, True, 0.5],
67
+ ["example_images/009962.jpg", 0.6, 0.7, True, 0.5],
68
+ ],
69
+ layout="horizontal"
70
+ ).launch()