Closed caitou2019 closed 1 year ago
Isn't YOLOv5 written in Python+Pytroch natively? I guess so... C-code must be happen to create proper CGO bindings :)
There are some interesting readings:
I don't think v5 will be supported by actual maintainers of Darknet
Well Now I have plans for YoloV7 since this is official - https://github.com/AlexeyAB/darknet/issues/8595
@LdDl @AlexeyAB It is a very good new that the darknet will support the training and inference of YOLOV7.
YOLOv7 tiny should work without additional effort: https://github.com/LdDl/go-darknet/commit/1969bdad71d96fa533085d8a068811b9f90448d2
~/go_work/go-darknet/cmd/examples$ go build -o base_example/main base_example/main.go && ./base_example/main --configFile=yolov7-tiny.cfg --weightsFile=yolov7-tiny.weights --imageFile=sample.jpg
Try to load cfg: yolov7-tiny.cfg, clear = 0
0 : compute_capability = 860, cudnn_half = 0, GPU: NVIDIA GeForce RTX 3060
net.optimized_memory = 0
mini_batch = 1, batch = 1, time_steps = 1, train = 1
layer filters size/strd(dil) input output
0 Create CUDA-stream - 0
Create cudnn-handle 0
conv 32 3 x 3/ 2 416 x 416 x 3 -> 208 x 208 x 32 0.075 BF
1 conv 64 3 x 3/ 2 208 x 208 x 32 -> 104 x 104 x 64 0.399 BF
2 conv 32 1 x 1/ 1 104 x 104 x 64 -> 104 x 104 x 32 0.044 BF
3 route 1 -> 104 x 104 x 64
4 conv 32 1 x 1/ 1 104 x 104 x 64 -> 104 x 104 x 32 0.044 BF
5 conv 32 3 x 3/ 1 104 x 104 x 32 -> 104 x 104 x 32 0.199 BF
6 conv 32 3 x 3/ 1 104 x 104 x 32 -> 104 x 104 x 32 0.199 BF
7 route 2 4 5 6 -> 104 x 104 x 128
8 conv 64 1 x 1/ 1 104 x 104 x 128 -> 104 x 104 x 64 0.177 BF
9 max 2x 2/ 2 104 x 104 x 64 -> 52 x 52 x 64 0.001 BF
10 conv 64 1 x 1/ 1 52 x 52 x 64 -> 52 x 52 x 64 0.022 BF
11 route 9 -> 52 x 52 x 64
12 conv 64 1 x 1/ 1 52 x 52 x 64 -> 52 x 52 x 64 0.022 BF
13 conv 64 3 x 3/ 1 52 x 52 x 64 -> 52 x 52 x 64 0.199 BF
14 conv 64 3 x 3/ 1 52 x 52 x 64 -> 52 x 52 x 64 0.199 BF
15 route 10 12 13 14 -> 52 x 52 x 256
16 conv 128 1 x 1/ 1 52 x 52 x 256 -> 52 x 52 x 128 0.177 BF
17 max 2x 2/ 2 52 x 52 x 128 -> 26 x 26 x 128 0.000 BF
18 conv 128 1 x 1/ 1 26 x 26 x 128 -> 26 x 26 x 128 0.022 BF
19 route 17 -> 26 x 26 x 128
20 conv 128 1 x 1/ 1 26 x 26 x 128 -> 26 x 26 x 128 0.022 BF
21 conv 128 3 x 3/ 1 26 x 26 x 128 -> 26 x 26 x 128 0.199 BF
22 conv 128 3 x 3/ 1 26 x 26 x 128 -> 26 x 26 x 128 0.199 BF
23 route 18 20 21 22 -> 26 x 26 x 512
24 conv 256 1 x 1/ 1 26 x 26 x 512 -> 26 x 26 x 256 0.177 BF
25 max 2x 2/ 2 26 x 26 x 256 -> 13 x 13 x 256 0.000 BF
26 conv 256 1 x 1/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.022 BF
27 route 25 -> 13 x 13 x 256
28 conv 256 1 x 1/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.022 BF
29 conv 256 3 x 3/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.199 BF
30 conv 256 3 x 3/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.199 BF
31 route 26 28 29 30 -> 13 x 13 x1024
32 conv 512 1 x 1/ 1 13 x 13 x1024 -> 13 x 13 x 512 0.177 BF
33 conv 256 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 256 0.044 BF
34 route 32 -> 13 x 13 x 512
35 conv 256 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 256 0.044 BF
36 max 5x 5/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.001 BF
37 route 35 -> 13 x 13 x 256
38 max 9x 9/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.004 BF
39 route 35 -> 13 x 13 x 256
40 max 13x13/ 1 13 x 13 x 256 -> 13 x 13 x 256 0.007 BF
41 route 40 38 36 35 -> 13 x 13 x1024
42 conv 256 1 x 1/ 1 13 x 13 x1024 -> 13 x 13 x 256 0.089 BF
43 route 33 42 -> 13 x 13 x 512
44 conv 256 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 256 0.044 BF
45 conv 128 1 x 1/ 1 13 x 13 x 256 -> 13 x 13 x 128 0.011 BF
46 upsample 2x 13 x 13 x 128 -> 26 x 26 x 128
47 route 24 -> 26 x 26 x 256
48 conv 128 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 128 0.044 BF
49 route 48 46 -> 26 x 26 x 256
50 conv 64 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 64 0.022 BF
51 route 49 -> 26 x 26 x 256
52 conv 64 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 64 0.022 BF
53 conv 64 3 x 3/ 1 26 x 26 x 64 -> 26 x 26 x 64 0.050 BF
54 conv 64 3 x 3/ 1 26 x 26 x 64 -> 26 x 26 x 64 0.050 BF
55 route 50 52 53 54 -> 26 x 26 x 256
56 conv 128 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 128 0.044 BF
57 conv 64 1 x 1/ 1 26 x 26 x 128 -> 26 x 26 x 64 0.011 BF
58 upsample 2x 26 x 26 x 64 -> 52 x 52 x 64
59 route 16 -> 52 x 52 x 128
60 conv 64 1 x 1/ 1 52 x 52 x 128 -> 52 x 52 x 64 0.044 BF
61 route 60 58 -> 52 x 52 x 128
62 conv 32 1 x 1/ 1 52 x 52 x 128 -> 52 x 52 x 32 0.022 BF
63 route 61 -> 52 x 52 x 128
64 conv 32 1 x 1/ 1 52 x 52 x 128 -> 52 x 52 x 32 0.022 BF
65 conv 32 3 x 3/ 1 52 x 52 x 32 -> 52 x 52 x 32 0.050 BF
66 conv 32 3 x 3/ 1 52 x 52 x 32 -> 52 x 52 x 32 0.050 BF
67 route 62 64 65 66 -> 52 x 52 x 128
68 conv 64 1 x 1/ 1 52 x 52 x 128 -> 52 x 52 x 64 0.044 BF
69 conv 128 3 x 3/ 2 52 x 52 x 64 -> 26 x 26 x 128 0.100 BF
70 route 69 56 -> 26 x 26 x 256
71 conv 64 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 64 0.022 BF
72 route 70 -> 26 x 26 x 256
73 conv 64 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 64 0.022 BF
74 conv 64 3 x 3/ 1 26 x 26 x 64 -> 26 x 26 x 64 0.050 BF
75 conv 64 3 x 3/ 1 26 x 26 x 64 -> 26 x 26 x 64 0.050 BF
76 route 71 73 74 75 -> 26 x 26 x 256
77 conv 128 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 128 0.044 BF
78 conv 256 3 x 3/ 2 26 x 26 x 128 -> 13 x 13 x 256 0.100 BF
79 route 78 44 -> 13 x 13 x 512
80 conv 128 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 128 0.022 BF
81 route 79 -> 13 x 13 x 512
82 conv 128 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 128 0.022 BF
83 conv 128 3 x 3/ 1 13 x 13 x 128 -> 13 x 13 x 128 0.050 BF
84 conv 128 3 x 3/ 1 13 x 13 x 128 -> 13 x 13 x 128 0.050 BF
85 route 80 82 83 84 -> 13 x 13 x 512
86 conv 256 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 256 0.044 BF
87 route 68 -> 52 x 52 x 64
88 conv 128 3 x 3/ 1 52 x 52 x 64 -> 52 x 52 x 128 0.399 BF
89 conv 255 1 x 1/ 1 52 x 52 x 128 -> 52 x 52 x 255 0.177 BF
90 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.05, obj_norm: 1.00, cls_norm: 0.50, delta_norm: 1.00, scale_x_y: 2.00
nms_kind: diounms (2), beta = 0.600000
91 route 77 -> 26 x 26 x 128
92 conv 256 3 x 3/ 1 26 x 26 x 128 -> 26 x 26 x 256 0.399 BF
93 conv 255 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 255 0.088 BF
94 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.05, obj_norm: 1.00, cls_norm: 0.50, delta_norm: 1.00, scale_x_y: 2.00
nms_kind: diounms (2), beta = 0.600000
95 route 86 -> 13 x 13 x 256
96 conv 512 3 x 3/ 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BF
97 conv 255 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 255 0.044 BF
98 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.05, obj_norm: 1.00, cls_norm: 0.50, delta_norm: 1.00, scale_x_y: 2.00
nms_kind: diounms (2), beta = 0.600000
Unused field: 'names = coco.names'
Total BFLOPS 5.802
avg_outputs = 182380
Allocate additional workspace_size = 9.34 MB
Try to load weights: yolov7-tiny.weights
Loading weights from yolov7-tiny.weights...
seen 64, trained: 0 K-images (0 Kilo-batches_64)
Done! Loaded 99 layers from weights-file
Loaded - names_list: coco.names, classes = 80
2022/07/13 16:13:15 Network-only time taken: 7.88269ms
2022/07/13 16:13:15 Overall time taken: 8.386104ms 101
truck (7): 53.2890% | start point: (0,143) | end point: (89, 328)
truck (7): 42.1364% | start point: (685,182) | end point: (800, 318)
truck (7): 26.9703% | start point: (437,170) | end point: (560, 217)
car (2): 87.7818% | start point: (509,189) | end point: (742, 329)
car (2): 87.5633% | start point: (262,191) | end point: (423, 322)
car (2): 85.4743% | start point: (427,198) | end point: (549, 309)
car (2): 71.3772% | start point: (0,147) | end point: (87, 327)
car (2): 62.5698% | start point: (98,151) | end point: (197, 286)
car (2): 61.5811% | start point: (693,186) | end point: (799, 316)
car (2): 49.6343% | start point: (386,206) | end point: (441, 286)
car (2): 28.2012% | start point: (386,205) | end point: (440, 236)
bicycle (1): 71.9609% | start point: (179,294) | end point: (249, 405)
person (0): 85.4390% | start point: (146,130) | end point: (269, 351)
Comparing to YOLO v4 tiny:
~/go_work/go-darknet/cmd/examples$ go build -o base_example/main base_example/main.go && ./base_example/main --configFile=yolov4-tiny.cfg --weightsFile=yolov4-tiny.weights --imageFile=sample.jpg
Try to load cfg: yolov4-tiny.cfg, clear = 0
0 : compute_capability = 860, cudnn_half = 0, GPU: NVIDIA GeForce RTX 3060
net.optimized_memory = 0
mini_batch = 1, batch = 1, time_steps = 1, train = 1
layer filters size/strd(dil) input output
0 Create CUDA-stream - 0
Create cudnn-handle 0
conv 32 3 x 3/ 2 416 x 416 x 3 -> 208 x 208 x 32 0.075 BF
1 conv 64 3 x 3/ 2 208 x 208 x 32 -> 104 x 104 x 64 0.399 BF
2 conv 64 3 x 3/ 1 104 x 104 x 64 -> 104 x 104 x 64 0.797 BF
3 route 2 1/2 -> 104 x 104 x 32
4 conv 32 3 x 3/ 1 104 x 104 x 32 -> 104 x 104 x 32 0.199 BF
5 conv 32 3 x 3/ 1 104 x 104 x 32 -> 104 x 104 x 32 0.199 BF
6 route 5 4 -> 104 x 104 x 64
7 conv 64 1 x 1/ 1 104 x 104 x 64 -> 104 x 104 x 64 0.089 BF
8 route 2 7 -> 104 x 104 x 128
9 max 2x 2/ 2 104 x 104 x 128 -> 52 x 52 x 128 0.001 BF
10 conv 128 3 x 3/ 1 52 x 52 x 128 -> 52 x 52 x 128 0.797 BF
11 route 10 1/2 -> 52 x 52 x 64
12 conv 64 3 x 3/ 1 52 x 52 x 64 -> 52 x 52 x 64 0.199 BF
13 conv 64 3 x 3/ 1 52 x 52 x 64 -> 52 x 52 x 64 0.199 BF
14 route 13 12 -> 52 x 52 x 128
15 conv 128 1 x 1/ 1 52 x 52 x 128 -> 52 x 52 x 128 0.089 BF
16 route 10 15 -> 52 x 52 x 256
17 max 2x 2/ 2 52 x 52 x 256 -> 26 x 26 x 256 0.001 BF
18 conv 256 3 x 3/ 1 26 x 26 x 256 -> 26 x 26 x 256 0.797 BF
19 route 18 1/2 -> 26 x 26 x 128
20 conv 128 3 x 3/ 1 26 x 26 x 128 -> 26 x 26 x 128 0.199 BF
21 conv 128 3 x 3/ 1 26 x 26 x 128 -> 26 x 26 x 128 0.199 BF
22 route 21 20 -> 26 x 26 x 256
23 conv 256 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 256 0.089 BF
24 route 18 23 -> 26 x 26 x 512
25 max 2x 2/ 2 26 x 26 x 512 -> 13 x 13 x 512 0.000 BF
26 conv 512 3 x 3/ 1 13 x 13 x 512 -> 13 x 13 x 512 0.797 BF
27 conv 256 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 256 0.044 BF
28 conv 512 3 x 3/ 1 13 x 13 x 256 -> 13 x 13 x 512 0.399 BF
29 conv 255 1 x 1/ 1 13 x 13 x 512 -> 13 x 13 x 255 0.044 BF
30 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.05
nms_kind: greedynms (1), beta = 0.600000
31 route 27 -> 13 x 13 x 256
32 conv 128 1 x 1/ 1 13 x 13 x 256 -> 13 x 13 x 128 0.011 BF
33 upsample 2x 13 x 13 x 128 -> 26 x 26 x 128
34 route 33 23 -> 26 x 26 x 384
35 conv 256 3 x 3/ 1 26 x 26 x 384 -> 26 x 26 x 256 1.196 BF
36 conv 255 1 x 1/ 1 26 x 26 x 256 -> 26 x 26 x 255 0.088 BF
37 yolo
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, obj_norm: 1.00, cls_norm: 1.00, delta_norm: 1.00, scale_x_y: 1.05
nms_kind: greedynms (1), beta = 0.600000
Unused field: 'names = coco.names'
Total BFLOPS 6.910
avg_outputs = 310203
Allocate additional workspace_size = 13.80 MB
Try to load weights: yolov4-tiny.weights
Loading weights from yolov4-tiny.weights...
seen 64, trained: 0 K-images (0 Kilo-batches_64)
Done! Loaded 38 layers from weights-file
Loaded - names_list: coco.names, classes = 80
2022/07/13 16:19:28 Network-only time taken: 6.694944ms
2022/07/13 16:19:28 Overall time taken: 6.854318ms 30
truck (7): 77.7936% | start point: (0,138) | end point: (90, 332)
truck (7): 55.9773% | start point: (696,174) | end point: (799, 314)
car (2): 53.1286% | start point: (696,184) | end point: (799, 319)
car (2): 98.0222% | start point: (262,189) | end point: (424, 330)
car (2): 97.8773% | start point: (430,190) | end point: (542, 313)
car (2): 81.4099% | start point: (510,190) | end point: (743, 325)
car (2): 43.3935% | start point: (391,207) | end point: (435, 299)
car (2): 37.4221% | start point: (386,206) | end point: (429, 239)
car (2): 32.0724% | start point: (109,196) | end point: (157, 289)
person (0): 73.0868% | start point: (154,132) | end point: (284, 382)
I see that accuracy improvements in v7-tiny variation, but inference a bit fast in v4-tiny
Do we have any plans to support Yolo-V5 in this project?