ultralytics 8.2.17__py3-none-any.whl → 8.2.19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ultralytics might be problematic. Click here for more details.
- ultralytics/__init__.py +1 -1
- ultralytics/cfg/datasets/signature.yaml +20 -0
- ultralytics/cfg/models/v9/yolov9c-seg.yaml +22 -22
- ultralytics/cfg/models/v9/yolov9c.yaml +22 -22
- ultralytics/cfg/models/v9/yolov9e-seg.yaml +34 -34
- ultralytics/cfg/models/v9/yolov9e.yaml +34 -34
- ultralytics/data/build.py +1 -1
- ultralytics/engine/exporter.py +3 -0
- ultralytics/solutions/__init__.py +18 -0
- ultralytics/solutions/ai_gym.py +53 -79
- ultralytics/solutions/distance_calculation.py +66 -71
- ultralytics/solutions/heatmap.py +95 -133
- ultralytics/solutions/object_counter.py +62 -82
- ultralytics/solutions/parking_management.py +22 -9
- ultralytics/solutions/queue_management.py +63 -82
- ultralytics/solutions/speed_estimation.py +50 -68
- ultralytics/utils/plotting.py +40 -42
- {ultralytics-8.2.17.dist-info → ultralytics-8.2.19.dist-info}/METADATA +1 -1
- {ultralytics-8.2.17.dist-info → ultralytics-8.2.19.dist-info}/RECORD +23 -22
- {ultralytics-8.2.17.dist-info → ultralytics-8.2.19.dist-info}/LICENSE +0 -0
- {ultralytics-8.2.17.dist-info → ultralytics-8.2.19.dist-info}/WHEEL +0 -0
- {ultralytics-8.2.17.dist-info → ultralytics-8.2.19.dist-info}/entry_points.txt +0 -0
- {ultralytics-8.2.17.dist-info → ultralytics-8.2.19.dist-info}/top_level.txt +0 -0
ultralytics/__init__.py
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
2
|
+
# Signature dataset by Ultralytics
|
|
3
|
+
# Documentation: https://docs.ultralytics.com/datasets/detect/signature/
|
|
4
|
+
# Example usage: yolo train data=signature.yaml
|
|
5
|
+
# parent
|
|
6
|
+
# ├── ultralytics
|
|
7
|
+
# └── datasets
|
|
8
|
+
# └── signature ← downloads here (11.2 MB)
|
|
9
|
+
|
|
10
|
+
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
|
|
11
|
+
path: ../datasets/signature # dataset root dir
|
|
12
|
+
train: train/images # train images (relative to 'path') 143 images
|
|
13
|
+
val: valid/images # val images (relative to 'path') 35 images
|
|
14
|
+
|
|
15
|
+
# Classes
|
|
16
|
+
names:
|
|
17
|
+
0: signature
|
|
18
|
+
|
|
19
|
+
# Download script/URL (optional)
|
|
20
|
+
download: https://ultralytics.com/assets/signature.zip
|
|
@@ -3,36 +3,36 @@
|
|
|
3
3
|
# 654 layers, 27897120 parameters, 159.4 GFLOPs
|
|
4
4
|
|
|
5
5
|
# parameters
|
|
6
|
-
nc: 80
|
|
6
|
+
nc: 80 # number of classes
|
|
7
7
|
|
|
8
8
|
# gelan backbone
|
|
9
9
|
backbone:
|
|
10
|
-
- [-1, 1, Conv, [64, 3, 2]]
|
|
11
|
-
- [-1, 1, Conv, [128, 3, 2]]
|
|
12
|
-
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]]
|
|
13
|
-
- [-1, 1, ADown, [256]]
|
|
14
|
-
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]]
|
|
15
|
-
- [-1, 1, ADown, [512]]
|
|
16
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
17
|
-
- [-1, 1, ADown, [512]]
|
|
18
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
19
|
-
- [-1, 1, SPPELAN, [512, 256]]
|
|
10
|
+
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
|
|
11
|
+
- [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
|
|
12
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]] # 2
|
|
13
|
+
- [-1, 1, ADown, [256]] # 3-P3/8
|
|
14
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]] # 4
|
|
15
|
+
- [-1, 1, ADown, [512]] # 5-P4/16
|
|
16
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 6
|
|
17
|
+
- [-1, 1, ADown, [512]] # 7-P5/32
|
|
18
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 8
|
|
19
|
+
- [-1, 1, SPPELAN, [512, 256]] # 9
|
|
20
20
|
|
|
21
21
|
head:
|
|
22
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
23
|
-
- [[-1, 6], 1, Concat, [1]]
|
|
24
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
22
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
23
|
+
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
|
|
24
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 12
|
|
25
25
|
|
|
26
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
27
|
-
- [[-1, 4], 1, Concat, [1]]
|
|
28
|
-
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]]
|
|
26
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
27
|
+
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
28
|
+
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]] # 15 (P3/8-small)
|
|
29
29
|
|
|
30
30
|
- [-1, 1, ADown, [256]]
|
|
31
|
-
- [[-1, 12], 1, Concat, [1]]
|
|
32
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
31
|
+
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
32
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 18 (P4/16-medium)
|
|
33
33
|
|
|
34
34
|
- [-1, 1, ADown, [512]]
|
|
35
|
-
- [[-1, 9], 1, Concat, [1]]
|
|
36
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
35
|
+
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
36
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 21 (P5/32-large)
|
|
37
37
|
|
|
38
|
-
- [[15, 18, 21], 1, Segment, [nc, 32, 256]]
|
|
38
|
+
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Segment(P3, P4, P5)
|
|
@@ -3,36 +3,36 @@
|
|
|
3
3
|
# 618 layers, 25590912 parameters, 104.0 GFLOPs
|
|
4
4
|
|
|
5
5
|
# parameters
|
|
6
|
-
nc: 80
|
|
6
|
+
nc: 80 # number of classes
|
|
7
7
|
|
|
8
8
|
# gelan backbone
|
|
9
9
|
backbone:
|
|
10
|
-
- [-1, 1, Conv, [64, 3, 2]]
|
|
11
|
-
- [-1, 1, Conv, [128, 3, 2]]
|
|
12
|
-
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]]
|
|
13
|
-
- [-1, 1, ADown, [256]]
|
|
14
|
-
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]]
|
|
15
|
-
- [-1, 1, ADown, [512]]
|
|
16
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
17
|
-
- [-1, 1, ADown, [512]]
|
|
18
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
19
|
-
- [-1, 1, SPPELAN, [512, 256]]
|
|
10
|
+
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
|
|
11
|
+
- [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
|
|
12
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]] # 2
|
|
13
|
+
- [-1, 1, ADown, [256]] # 3-P3/8
|
|
14
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]] # 4
|
|
15
|
+
- [-1, 1, ADown, [512]] # 5-P4/16
|
|
16
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 6
|
|
17
|
+
- [-1, 1, ADown, [512]] # 7-P5/32
|
|
18
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 8
|
|
19
|
+
- [-1, 1, SPPELAN, [512, 256]] # 9
|
|
20
20
|
|
|
21
21
|
head:
|
|
22
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
23
|
-
- [[-1, 6], 1, Concat, [1]]
|
|
24
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
22
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
23
|
+
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
|
|
24
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 12
|
|
25
25
|
|
|
26
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
27
|
-
- [[-1, 4], 1, Concat, [1]]
|
|
28
|
-
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]]
|
|
26
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
27
|
+
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
28
|
+
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]] # 15 (P3/8-small)
|
|
29
29
|
|
|
30
30
|
- [-1, 1, ADown, [256]]
|
|
31
|
-
- [[-1, 12], 1, Concat, [1]]
|
|
32
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
31
|
+
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
32
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 18 (P4/16-medium)
|
|
33
33
|
|
|
34
34
|
- [-1, 1, ADown, [512]]
|
|
35
|
-
- [[-1, 9], 1, Concat, [1]]
|
|
36
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]]
|
|
35
|
+
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
36
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 21 (P5/32-large)
|
|
37
37
|
|
|
38
|
-
- [[15, 18, 21], 1, Detect, [nc]]
|
|
38
|
+
- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
# 1261 layers, 60512800 parameters, 248.4 GFLOPs
|
|
4
4
|
|
|
5
5
|
# parameters
|
|
6
|
-
nc: 80
|
|
6
|
+
nc: 80 # number of classes
|
|
7
7
|
|
|
8
8
|
# gelan backbone
|
|
9
9
|
backbone:
|
|
10
10
|
- [-1, 1, Silence, []]
|
|
11
|
-
- [-1, 1, Conv, [64, 3, 2]]
|
|
12
|
-
- [-1, 1, Conv, [128, 3, 2]]
|
|
13
|
-
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]]
|
|
14
|
-
- [-1, 1, ADown, [256]]
|
|
15
|
-
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]]
|
|
16
|
-
- [-1, 1, ADown, [512]]
|
|
17
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
18
|
-
- [-1, 1, ADown, [1024]]
|
|
19
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
11
|
+
- [-1, 1, Conv, [64, 3, 2]] # 1-P1/2
|
|
12
|
+
- [-1, 1, Conv, [128, 3, 2]] # 2-P2/4
|
|
13
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 3
|
|
14
|
+
- [-1, 1, ADown, [256]] # 4-P3/8
|
|
15
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 5
|
|
16
|
+
- [-1, 1, ADown, [512]] # 6-P4/16
|
|
17
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 7
|
|
18
|
+
- [-1, 1, ADown, [1024]] # 8-P5/32
|
|
19
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 9
|
|
20
20
|
|
|
21
21
|
- [1, 1, CBLinear, [[64]]] # 10
|
|
22
22
|
- [3, 1, CBLinear, [[64, 128]]] # 11
|
|
@@ -24,38 +24,38 @@ backbone:
|
|
|
24
24
|
- [7, 1, CBLinear, [[64, 128, 256, 512]]] # 13
|
|
25
25
|
- [9, 1, CBLinear, [[64, 128, 256, 512, 1024]]] # 14
|
|
26
26
|
|
|
27
|
-
- [0, 1, Conv, [64, 3, 2]]
|
|
27
|
+
- [0, 1, Conv, [64, 3, 2]] # 15-P1/2
|
|
28
28
|
- [[10, 11, 12, 13, 14, -1], 1, CBFuse, [[0, 0, 0, 0, 0]]] # 16
|
|
29
|
-
- [-1, 1, Conv, [128, 3, 2]]
|
|
30
|
-
- [[11, 12, 13, 14, -1], 1, CBFuse, [[1, 1, 1, 1]]] # 18
|
|
31
|
-
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]]
|
|
32
|
-
- [-1, 1, ADown, [256]]
|
|
33
|
-
- [[12, 13, 14, -1], 1, CBFuse, [[2, 2, 2]]] # 21
|
|
34
|
-
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]]
|
|
35
|
-
- [-1, 1, ADown, [512]]
|
|
36
|
-
- [[13, 14, -1], 1, CBFuse, [[3, 3]]] # 24
|
|
37
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
38
|
-
- [-1, 1, ADown, [1024]]
|
|
29
|
+
- [-1, 1, Conv, [128, 3, 2]] # 17-P2/4
|
|
30
|
+
- [[11, 12, 13, 14, -1], 1, CBFuse, [[1, 1, 1, 1]]] # 18
|
|
31
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 19
|
|
32
|
+
- [-1, 1, ADown, [256]] # 20-P3/8
|
|
33
|
+
- [[12, 13, 14, -1], 1, CBFuse, [[2, 2, 2]]] # 21
|
|
34
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 22
|
|
35
|
+
- [-1, 1, ADown, [512]] # 23-P4/16
|
|
36
|
+
- [[13, 14, -1], 1, CBFuse, [[3, 3]]] # 24
|
|
37
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 25
|
|
38
|
+
- [-1, 1, ADown, [1024]] # 26-P5/32
|
|
39
39
|
- [[14, -1], 1, CBFuse, [[4]]] # 27
|
|
40
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
41
|
-
- [-1, 1, SPPELAN, [512, 256]]
|
|
40
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 28
|
|
41
|
+
- [-1, 1, SPPELAN, [512, 256]] # 29
|
|
42
42
|
|
|
43
43
|
# gelan head
|
|
44
44
|
head:
|
|
45
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
46
|
-
- [[-1, 25], 1, Concat, [1]]
|
|
47
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]]
|
|
45
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
46
|
+
- [[-1, 25], 1, Concat, [1]] # cat backbone P4
|
|
47
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 32
|
|
48
48
|
|
|
49
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
50
|
-
- [[-1, 22], 1, Concat, [1]]
|
|
51
|
-
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 2]]
|
|
49
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
50
|
+
- [[-1, 22], 1, Concat, [1]] # cat backbone P3
|
|
51
|
+
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 2]] # 35 (P3/8-small)
|
|
52
52
|
|
|
53
53
|
- [-1, 1, ADown, [256]]
|
|
54
|
-
- [[-1, 32], 1, Concat, [1]]
|
|
55
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]]
|
|
54
|
+
- [[-1, 32], 1, Concat, [1]] # cat head P4
|
|
55
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 38 (P4/16-medium)
|
|
56
56
|
|
|
57
57
|
- [-1, 1, ADown, [512]]
|
|
58
|
-
- [[-1, 29], 1, Concat, [1]]
|
|
59
|
-
- [-1, 1, RepNCSPELAN4, [512, 1024, 512, 2]]
|
|
58
|
+
- [[-1, 29], 1, Concat, [1]] # cat head P5
|
|
59
|
+
- [-1, 1, RepNCSPELAN4, [512, 1024, 512, 2]] # 41 (P5/32-large)
|
|
60
60
|
|
|
61
|
-
- [[35, 38, 41], 1, Segment, [nc, 32, 256]]
|
|
61
|
+
- [[35, 38, 41], 1, Segment, [nc, 32, 256]] # Segment (P3, P4, P5)
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
# 1225 layers, 58206592 parameters, 193.0 GFLOPs
|
|
4
4
|
|
|
5
5
|
# parameters
|
|
6
|
-
nc: 80
|
|
6
|
+
nc: 80 # number of classes
|
|
7
7
|
|
|
8
8
|
# gelan backbone
|
|
9
9
|
backbone:
|
|
10
10
|
- [-1, 1, Silence, []]
|
|
11
|
-
- [-1, 1, Conv, [64, 3, 2]]
|
|
12
|
-
- [-1, 1, Conv, [128, 3, 2]]
|
|
13
|
-
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]]
|
|
14
|
-
- [-1, 1, ADown, [256]]
|
|
15
|
-
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]]
|
|
16
|
-
- [-1, 1, ADown, [512]]
|
|
17
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
18
|
-
- [-1, 1, ADown, [1024]]
|
|
19
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
11
|
+
- [-1, 1, Conv, [64, 3, 2]] # 1-P1/2
|
|
12
|
+
- [-1, 1, Conv, [128, 3, 2]] # 2-P2/4
|
|
13
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 3
|
|
14
|
+
- [-1, 1, ADown, [256]] # 4-P3/8
|
|
15
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 5
|
|
16
|
+
- [-1, 1, ADown, [512]] # 6-P4/16
|
|
17
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 7
|
|
18
|
+
- [-1, 1, ADown, [1024]] # 8-P5/32
|
|
19
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 9
|
|
20
20
|
|
|
21
21
|
- [1, 1, CBLinear, [[64]]] # 10
|
|
22
22
|
- [3, 1, CBLinear, [[64, 128]]] # 11
|
|
@@ -24,38 +24,38 @@ backbone:
|
|
|
24
24
|
- [7, 1, CBLinear, [[64, 128, 256, 512]]] # 13
|
|
25
25
|
- [9, 1, CBLinear, [[64, 128, 256, 512, 1024]]] # 14
|
|
26
26
|
|
|
27
|
-
- [0, 1, Conv, [64, 3, 2]]
|
|
27
|
+
- [0, 1, Conv, [64, 3, 2]] # 15-P1/2
|
|
28
28
|
- [[10, 11, 12, 13, 14, -1], 1, CBFuse, [[0, 0, 0, 0, 0]]] # 16
|
|
29
|
-
- [-1, 1, Conv, [128, 3, 2]]
|
|
30
|
-
- [[11, 12, 13, 14, -1], 1, CBFuse, [[1, 1, 1, 1]]] # 18
|
|
31
|
-
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]]
|
|
32
|
-
- [-1, 1, ADown, [256]]
|
|
33
|
-
- [[12, 13, 14, -1], 1, CBFuse, [[2, 2, 2]]] # 21
|
|
34
|
-
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]]
|
|
35
|
-
- [-1, 1, ADown, [512]]
|
|
36
|
-
- [[13, 14, -1], 1, CBFuse, [[3, 3]]] # 24
|
|
37
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
38
|
-
- [-1, 1, ADown, [1024]]
|
|
29
|
+
- [-1, 1, Conv, [128, 3, 2]] # 17-P2/4
|
|
30
|
+
- [[11, 12, 13, 14, -1], 1, CBFuse, [[1, 1, 1, 1]]] # 18
|
|
31
|
+
- [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 19
|
|
32
|
+
- [-1, 1, ADown, [256]] # 20-P3/8
|
|
33
|
+
- [[12, 13, 14, -1], 1, CBFuse, [[2, 2, 2]]] # 21
|
|
34
|
+
- [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 22
|
|
35
|
+
- [-1, 1, ADown, [512]] # 23-P4/16
|
|
36
|
+
- [[13, 14, -1], 1, CBFuse, [[3, 3]]] # 24
|
|
37
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 25
|
|
38
|
+
- [-1, 1, ADown, [1024]] # 26-P5/32
|
|
39
39
|
- [[14, -1], 1, CBFuse, [[4]]] # 27
|
|
40
|
-
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]]
|
|
41
|
-
- [-1, 1, SPPELAN, [512, 256]]
|
|
40
|
+
- [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 28
|
|
41
|
+
- [-1, 1, SPPELAN, [512, 256]] # 29
|
|
42
42
|
|
|
43
43
|
# gelan head
|
|
44
44
|
head:
|
|
45
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
46
|
-
- [[-1, 25], 1, Concat, [1]]
|
|
47
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]]
|
|
45
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
46
|
+
- [[-1, 25], 1, Concat, [1]] # cat backbone P4
|
|
47
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 32
|
|
48
48
|
|
|
49
|
-
- [-1, 1, nn.Upsample, [None, 2,
|
|
50
|
-
- [[-1, 22], 1, Concat, [1]]
|
|
51
|
-
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 2]]
|
|
49
|
+
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
|
50
|
+
- [[-1, 22], 1, Concat, [1]] # cat backbone P3
|
|
51
|
+
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 2]] # 35 (P3/8-small)
|
|
52
52
|
|
|
53
53
|
- [-1, 1, ADown, [256]]
|
|
54
|
-
- [[-1, 32], 1, Concat, [1]]
|
|
55
|
-
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]]
|
|
54
|
+
- [[-1, 32], 1, Concat, [1]] # cat head P4
|
|
55
|
+
- [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 38 (P4/16-medium)
|
|
56
56
|
|
|
57
57
|
- [-1, 1, ADown, [512]]
|
|
58
|
-
- [[-1, 29], 1, Concat, [1]]
|
|
59
|
-
- [-1, 1, RepNCSPELAN4, [512, 1024, 512, 2]]
|
|
58
|
+
- [[-1, 29], 1, Concat, [1]] # cat head P5
|
|
59
|
+
- [-1, 1, RepNCSPELAN4, [512, 1024, 512, 2]] # 41 (P5/32-large)
|
|
60
60
|
|
|
61
|
-
- [[35, 38, 41], 1, Detect, [nc]]
|
|
61
|
+
- [[35, 38, 41], 1, Detect, [nc]] # Detect(P3, P4, P5)
|
ultralytics/data/build.py
CHANGED
|
@@ -128,7 +128,7 @@ def build_dataloader(dataset, batch, workers, shuffle=True, rank=-1):
|
|
|
128
128
|
"""Return an InfiniteDataLoader or DataLoader for training or validation set."""
|
|
129
129
|
batch = min(batch, len(dataset))
|
|
130
130
|
nd = torch.cuda.device_count() # number of CUDA devices
|
|
131
|
-
nw = min(
|
|
131
|
+
nw = min(os.cpu_count() // max(nd, 1), workers) # number of workers
|
|
132
132
|
sampler = None if rank == -1 else distributed.DistributedSampler(dataset, shuffle=shuffle)
|
|
133
133
|
generator = torch.Generator()
|
|
134
134
|
generator.manual_seed(6148914691236517205 + RANK)
|
ultralytics/engine/exporter.py
CHANGED
|
@@ -195,6 +195,9 @@ class Exporter:
|
|
|
195
195
|
if not hasattr(model, "names"):
|
|
196
196
|
model.names = default_class_names()
|
|
197
197
|
model.names = check_class_names(model.names)
|
|
198
|
+
if self.args.half and self.args.int8:
|
|
199
|
+
LOGGER.warning("WARNING ⚠️ half=True and int8=True are mutually exclusive, setting half=False.")
|
|
200
|
+
self.args.half = False
|
|
198
201
|
if self.args.half and onnx and self.device.type == "cpu":
|
|
199
202
|
LOGGER.warning("WARNING ⚠️ half=True only compatible with GPU export, i.e. use device=0")
|
|
200
203
|
self.args.half = False
|
|
@@ -1 +1,19 @@
|
|
|
1
1
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
2
|
+
|
|
3
|
+
from .ai_gym import AIGym
|
|
4
|
+
from .distance_calculation import DistanceCalculation
|
|
5
|
+
from .heatmap import Heatmap
|
|
6
|
+
from .object_counter import ObjectCounter
|
|
7
|
+
from .parking_management import ParkingManagement
|
|
8
|
+
from .queue_management import QueueManager
|
|
9
|
+
from .speed_estimation import SpeedEstimator
|
|
10
|
+
|
|
11
|
+
__all__ = (
|
|
12
|
+
"AIGym",
|
|
13
|
+
"DistanceCalculation",
|
|
14
|
+
"Heatmap",
|
|
15
|
+
"ObjectCounter",
|
|
16
|
+
"ParkingManagement",
|
|
17
|
+
"QueueManager",
|
|
18
|
+
"SpeedEstimator",
|
|
19
|
+
)
|
ultralytics/solutions/ai_gym.py
CHANGED
|
@@ -9,79 +9,75 @@ from ultralytics.utils.plotting import Annotator
|
|
|
9
9
|
class AIGym:
|
|
10
10
|
"""A class to manage the gym steps of people in a real-time video stream based on their poses."""
|
|
11
11
|
|
|
12
|
-
def __init__(
|
|
13
|
-
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
kpts_to_check,
|
|
15
|
+
line_thickness=2,
|
|
16
|
+
view_img=False,
|
|
17
|
+
pose_up_angle=145.0,
|
|
18
|
+
pose_down_angle=90.0,
|
|
19
|
+
pose_type="pullup",
|
|
20
|
+
):
|
|
21
|
+
"""
|
|
22
|
+
Initializes the AIGym class with the specified parameters.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
kpts_to_check (list): Indices of keypoints to check.
|
|
26
|
+
line_thickness (int, optional): Thickness of the lines drawn. Defaults to 2.
|
|
27
|
+
view_img (bool, optional): Flag to display the image. Defaults to False.
|
|
28
|
+
pose_up_angle (float, optional): Angle threshold for the 'up' pose. Defaults to 145.0.
|
|
29
|
+
pose_down_angle (float, optional): Angle threshold for the 'down' pose. Defaults to 90.0.
|
|
30
|
+
pose_type (str, optional): Type of pose to detect ('pullup', 'pushup', 'abworkout'). Defaults to "pullup".
|
|
31
|
+
"""
|
|
14
32
|
|
|
15
33
|
# Image and line thickness
|
|
16
34
|
self.im0 = None
|
|
17
|
-
self.tf =
|
|
35
|
+
self.tf = line_thickness
|
|
18
36
|
|
|
19
37
|
# Keypoints and count information
|
|
20
38
|
self.keypoints = None
|
|
21
|
-
self.poseup_angle =
|
|
22
|
-
self.posedown_angle =
|
|
39
|
+
self.poseup_angle = pose_up_angle
|
|
40
|
+
self.posedown_angle = pose_down_angle
|
|
23
41
|
self.threshold = 0.001
|
|
24
42
|
|
|
25
43
|
# Store stage, count and angle information
|
|
26
44
|
self.angle = None
|
|
27
45
|
self.count = None
|
|
28
46
|
self.stage = None
|
|
29
|
-
self.pose_type =
|
|
30
|
-
self.kpts_to_check =
|
|
47
|
+
self.pose_type = pose_type
|
|
48
|
+
self.kpts_to_check = kpts_to_check
|
|
31
49
|
|
|
32
50
|
# Visual Information
|
|
33
|
-
self.view_img =
|
|
51
|
+
self.view_img = view_img
|
|
34
52
|
self.annotator = None
|
|
35
53
|
|
|
36
|
-
# Check if environment
|
|
54
|
+
# Check if environment supports imshow
|
|
37
55
|
self.env_check = check_imshow(warn=True)
|
|
38
56
|
|
|
39
|
-
def set_args(
|
|
40
|
-
self,
|
|
41
|
-
kpts_to_check,
|
|
42
|
-
line_thickness=2,
|
|
43
|
-
view_img=False,
|
|
44
|
-
pose_up_angle=145.0,
|
|
45
|
-
pose_down_angle=90.0,
|
|
46
|
-
pose_type="pullup",
|
|
47
|
-
):
|
|
48
|
-
"""
|
|
49
|
-
Configures the AIGym line_thickness, save image and view image parameters.
|
|
50
|
-
|
|
51
|
-
Args:
|
|
52
|
-
kpts_to_check (list): 3 keypoints for counting
|
|
53
|
-
line_thickness (int): Line thickness for bounding boxes.
|
|
54
|
-
view_img (bool): display the im0
|
|
55
|
-
pose_up_angle (float): Angle to set pose position up
|
|
56
|
-
pose_down_angle (float): Angle to set pose position down
|
|
57
|
-
pose_type (str): "pushup", "pullup" or "abworkout"
|
|
58
|
-
"""
|
|
59
|
-
self.kpts_to_check = kpts_to_check
|
|
60
|
-
self.tf = line_thickness
|
|
61
|
-
self.view_img = view_img
|
|
62
|
-
self.poseup_angle = pose_up_angle
|
|
63
|
-
self.posedown_angle = pose_down_angle
|
|
64
|
-
self.pose_type = pose_type
|
|
65
|
-
|
|
66
57
|
def start_counting(self, im0, results, frame_count):
|
|
67
58
|
"""
|
|
68
59
|
Function used to count the gym steps.
|
|
69
60
|
|
|
70
61
|
Args:
|
|
71
62
|
im0 (ndarray): Current frame from the video stream.
|
|
72
|
-
results (list): Pose estimation data
|
|
73
|
-
frame_count (int):
|
|
63
|
+
results (list): Pose estimation data.
|
|
64
|
+
frame_count (int): Current frame count.
|
|
74
65
|
"""
|
|
66
|
+
|
|
75
67
|
self.im0 = im0
|
|
68
|
+
|
|
69
|
+
# Initialize count, angle, and stage lists on the first frame
|
|
76
70
|
if frame_count == 1:
|
|
77
71
|
self.count = [0] * len(results[0])
|
|
78
72
|
self.angle = [0] * len(results[0])
|
|
79
73
|
self.stage = ["-" for _ in results[0]]
|
|
74
|
+
|
|
80
75
|
self.keypoints = results[0].keypoints.data
|
|
81
76
|
self.annotator = Annotator(im0, line_width=2)
|
|
82
77
|
|
|
83
78
|
for ind, k in enumerate(reversed(self.keypoints)):
|
|
84
|
-
|
|
79
|
+
# Estimate angle and draw specific points based on pose type
|
|
80
|
+
if self.pose_type in {"pushup", "pullup", "abworkout"}:
|
|
85
81
|
self.angle[ind] = self.annotator.estimate_pose_angle(
|
|
86
82
|
k[int(self.kpts_to_check[0])].cpu(),
|
|
87
83
|
k[int(self.kpts_to_check[1])].cpu(),
|
|
@@ -89,55 +85,32 @@ class AIGym:
|
|
|
89
85
|
)
|
|
90
86
|
self.im0 = self.annotator.draw_specific_points(k, self.kpts_to_check, shape=(640, 640), radius=10)
|
|
91
87
|
|
|
92
|
-
|
|
93
|
-
self.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
self.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
count_text=self.count[ind],
|
|
107
|
-
stage_text=self.stage[ind],
|
|
108
|
-
center_kpt=k[int(self.kpts_to_check[1])],
|
|
109
|
-
line_thickness=self.tf,
|
|
110
|
-
)
|
|
88
|
+
# Check and update pose stages and counts based on angle
|
|
89
|
+
if self.pose_type in {"abworkout", "pullup"}:
|
|
90
|
+
if self.angle[ind] > self.poseup_angle:
|
|
91
|
+
self.stage[ind] = "down"
|
|
92
|
+
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "down":
|
|
93
|
+
self.stage[ind] = "up"
|
|
94
|
+
self.count[ind] += 1
|
|
95
|
+
|
|
96
|
+
elif self.pose_type == "pushup":
|
|
97
|
+
if self.angle[ind] > self.poseup_angle:
|
|
98
|
+
self.stage[ind] = "up"
|
|
99
|
+
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "up":
|
|
100
|
+
self.stage[ind] = "down"
|
|
101
|
+
self.count[ind] += 1
|
|
111
102
|
|
|
112
|
-
if self.pose_type == "pushup":
|
|
113
|
-
if self.angle[ind] > self.poseup_angle:
|
|
114
|
-
self.stage[ind] = "up"
|
|
115
|
-
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "up":
|
|
116
|
-
self.stage[ind] = "down"
|
|
117
|
-
self.count[ind] += 1
|
|
118
|
-
self.annotator.plot_angle_and_count_and_stage(
|
|
119
|
-
angle_text=self.angle[ind],
|
|
120
|
-
count_text=self.count[ind],
|
|
121
|
-
stage_text=self.stage[ind],
|
|
122
|
-
center_kpt=k[int(self.kpts_to_check[1])],
|
|
123
|
-
line_thickness=self.tf,
|
|
124
|
-
)
|
|
125
|
-
if self.pose_type == "pullup":
|
|
126
|
-
if self.angle[ind] > self.poseup_angle:
|
|
127
|
-
self.stage[ind] = "down"
|
|
128
|
-
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "down":
|
|
129
|
-
self.stage[ind] = "up"
|
|
130
|
-
self.count[ind] += 1
|
|
131
103
|
self.annotator.plot_angle_and_count_and_stage(
|
|
132
104
|
angle_text=self.angle[ind],
|
|
133
105
|
count_text=self.count[ind],
|
|
134
106
|
stage_text=self.stage[ind],
|
|
135
107
|
center_kpt=k[int(self.kpts_to_check[1])],
|
|
136
|
-
line_thickness=self.tf,
|
|
137
108
|
)
|
|
138
109
|
|
|
110
|
+
# Draw keypoints
|
|
139
111
|
self.annotator.kpts(k, shape=(640, 640), radius=1, kpt_line=True)
|
|
140
112
|
|
|
113
|
+
# Display the image if environment supports it and view_img is True
|
|
141
114
|
if self.env_check and self.view_img:
|
|
142
115
|
cv2.imshow("Ultralytics YOLOv8 AI GYM", self.im0)
|
|
143
116
|
if cv2.waitKey(1) & 0xFF == ord("q"):
|
|
@@ -147,4 +120,5 @@ class AIGym:
|
|
|
147
120
|
|
|
148
121
|
|
|
149
122
|
if __name__ == "__main__":
|
|
150
|
-
|
|
123
|
+
kpts_to_check = [0, 1, 2] # example keypoints
|
|
124
|
+
aigym = AIGym(kpts_to_check)
|