π [Merge] branch 'SETUP' into MODELv2
Browse files- .gitignore +1 -1
- .pre-commit-config.yaml +13 -1
- README.md +5 -5
- docs/CONTRIBUTING.md +0 -2
- docs/HOWTO.md +7 -7
- pyproject.toml +1 -1
- requirements.txt +1 -1
- tests/test_model/test_yolo.py +1 -1
- yolo/config/config.yaml +0 -1
- yolo/config/dataset/coco.yaml +2 -2
- yolo/config/dataset/dev.yaml +1 -1
- yolo/config/general.yaml +1 -1
- yolo/config/model/v7-base.yaml +107 -107
- yolo/config/model/v9-c.yaml +10 -10
- yolo/config/task/inference.yaml +1 -1
- yolo/config/task/train.yaml +2 -2
- yolo/config/task/validation.yaml +1 -1
- yolo/tools/data_augmentation.py +6 -5
- yolo/utils/logging_utils.py +3 -3
.gitignore
CHANGED
@@ -145,4 +145,4 @@ runs
|
|
145 |
node_modules/
|
146 |
|
147 |
# Not ignore image for demo
|
148 |
-
!demo/images/inference/*
|
|
|
145 |
node_modules/
|
146 |
|
147 |
# Not ignore image for demo
|
148 |
+
!demo/images/inference/*
|
.pre-commit-config.yaml
CHANGED
@@ -6,9 +6,21 @@ repos:
|
|
6 |
language_version: python3 # Specify the Python version
|
7 |
exclude: '.*\.yaml$' # Regex pattern to exclude all YAML files
|
8 |
args: ["--line-length", "120"] # Set max line length to 100 characters
|
9 |
-
|
10 |
- repo: https://github.com/pre-commit/mirrors-isort
|
11 |
rev: v5.10.1 # Use the appropriate version or "stable" for the latest stable release
|
12 |
hooks:
|
13 |
- id: isort
|
14 |
args: ["--profile", "black"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
language_version: python3 # Specify the Python version
|
7 |
exclude: '.*\.yaml$' # Regex pattern to exclude all YAML files
|
8 |
args: ["--line-length", "120"] # Set max line length to 100 characters
|
9 |
+
|
10 |
- repo: https://github.com/pre-commit/mirrors-isort
|
11 |
rev: v5.10.1 # Use the appropriate version or "stable" for the latest stable release
|
12 |
hooks:
|
13 |
- id: isort
|
14 |
args: ["--profile", "black"]
|
15 |
+
|
16 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
17 |
+
rev: v3.4.0
|
18 |
+
hooks:
|
19 |
+
- id: trailing-whitespace
|
20 |
+
- id: end-of-file-fixer
|
21 |
+
- id: check-yaml
|
22 |
+
|
23 |
+
- repo: https://github.com/kynan/nbstripout
|
24 |
+
rev: 0.5.0
|
25 |
+
hooks:
|
26 |
+
- id: nbstripout
|
README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |

|
4 |
> [!IMPORTANT]
|
5 |
> This project is currently a Work In Progress and may undergo significant changes. It is not recommended for use in production environments until further notice. Please check back regularly for updates.
|
6 |
-
>
|
7 |
> Use of this code is at your own risk and discretion. It is advisable to consult with the project owner before deploying or integrating into any critical systems.
|
8 |
|
9 |
Welcome to the official implementation of YOLOv7 and YOLOv9. This repository will contains the complete codebase, pre-trained models, and detailed instructions for training and deploying YOLOv9.
|
@@ -55,14 +55,14 @@ python lazy.py task=train task.batch_size=8 model=v9-c
|
|
55 |
### Transfer Learning
|
56 |
To perform transfer learning with YOLOv9:
|
57 |
```shell
|
58 |
-
python lazy.py task=train task.batch_size=8 model=v9-c task.dataset={dataset_config}
|
59 |
```
|
60 |
|
61 |
### Inference
|
62 |
To evaluate the model performance, use:
|
63 |
```shell
|
64 |
python lazy.py weights=v9-c.pt # if cloned from GitHub
|
65 |
-
yolo task=inference task.source={Any} # if pip installed
|
66 |
```
|
67 |
|
68 |
### Validation [WIP]
|
@@ -80,11 +80,11 @@ Contributions to the YOLOv9 project are welcome! See [CONTRIBUTING](docs/CONTRIB
|
|
80 |
## Citations
|
81 |
```
|
82 |
@misc{wang2024yolov9,
|
83 |
-
title={YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information},
|
84 |
author={Chien-Yao Wang and I-Hau Yeh and Hong-Yuan Mark Liao},
|
85 |
year={2024},
|
86 |
eprint={2402.13616},
|
87 |
archivePrefix={arXiv},
|
88 |
primaryClass={cs.CV}
|
89 |
}
|
90 |
-
```
|
|
|
3 |

|
4 |
> [!IMPORTANT]
|
5 |
> This project is currently a Work In Progress and may undergo significant changes. It is not recommended for use in production environments until further notice. Please check back regularly for updates.
|
6 |
+
>
|
7 |
> Use of this code is at your own risk and discretion. It is advisable to consult with the project owner before deploying or integrating into any critical systems.
|
8 |
|
9 |
Welcome to the official implementation of YOLOv7 and YOLOv9. This repository will contains the complete codebase, pre-trained models, and detailed instructions for training and deploying YOLOv9.
|
|
|
55 |
### Transfer Learning
|
56 |
To perform transfer learning with YOLOv9:
|
57 |
```shell
|
58 |
+
python lazy.py task=train task.batch_size=8 model=v9-c task.data.dataset={dataset_config}
|
59 |
```
|
60 |
|
61 |
### Inference
|
62 |
To evaluate the model performance, use:
|
63 |
```shell
|
64 |
python lazy.py weights=v9-c.pt # if cloned from GitHub
|
65 |
+
yolo task=inference task.data.source={Any} # if pip installed
|
66 |
```
|
67 |
|
68 |
### Validation [WIP]
|
|
|
80 |
## Citations
|
81 |
```
|
82 |
@misc{wang2024yolov9,
|
83 |
+
title={YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information},
|
84 |
author={Chien-Yao Wang and I-Hau Yeh and Hong-Yuan Mark Liao},
|
85 |
year={2024},
|
86 |
eprint={2402.13616},
|
87 |
archivePrefix={arXiv},
|
88 |
primaryClass={cs.CV}
|
89 |
}
|
90 |
+
```
|
docs/CONTRIBUTING.md
CHANGED
@@ -40,5 +40,3 @@ Once you submit a PR, maintainers will review your work, suggest changes if nece
|
|
40 |
Your contributions are greatly appreciated and vital to the project's success!
|
41 |
|
42 |
Please feel free to contact [[email protected]](mailto:[email protected])!
|
43 |
-
|
44 |
-
|
|
|
40 |
Your contributions are greatly appreciated and vital to the project's success!
|
41 |
|
42 |
Please feel free to contact [[email protected]](mailto:[email protected])!
|
|
|
|
docs/HOWTO.md
CHANGED
@@ -7,7 +7,7 @@ To facilitate easy customization of the YOLO model, we've structured the codebas
|
|
7 |
You can change the model architecture simply by modifying the YAML configuration file. Here's how:
|
8 |
|
9 |
1. **Modify Architecture in Config:**
|
10 |
-
|
11 |
Navigate to your model's configuration file (typically formate like `yolo/config/model/v9-c.yaml`).
|
12 |
- Adjust the architecture settings under the `architecture` section. Ensure that every module you reference exists in `module.py`, or refer to the next section on how to add new modules.
|
13 |
|
@@ -40,7 +40,7 @@ To add or modify a block in the model:
|
|
40 |
1. **Create a New Module:**
|
41 |
|
42 |
Define a new class in `module.py` that inherits from `nn.Module`.
|
43 |
-
|
44 |
The constructor should accept `in_channels` as a parameter. Make sure to calculate `out_channels` based on your model's requirements or configure it through the YAML file using `args`.
|
45 |
|
46 |
```python
|
@@ -49,7 +49,7 @@ To add or modify a block in the model:
|
|
49 |
super().__init__()
|
50 |
self.module = # conv, bool, ...
|
51 |
def forward(self, x):
|
52 |
-
return self.module(x)
|
53 |
```
|
54 |
|
55 |
2. **Reference in Config:**
|
@@ -138,11 +138,11 @@ Custom transformations should be designed to accept an image and its bounding bo
|
|
138 |
- `func` draw_bboxes: given a image and list of bbox, draw bbox on the image
|
139 |
- `func` draw_model: visualize the given model
|
140 |
- **get_dataset**
|
141 |
-
- `func` download_file: for a given link,
|
142 |
-
- `func` unzip_file: unzip the
|
143 |
- `func` check_files: check if the dataset file numbers is correct
|
144 |
-
- `func` prepare_dataset: automatic
|
145 |
- **loss**
|
146 |
- `class` BoxLoss: a Custom Loss for bounding box
|
147 |
- `class` YOLOLoss: a implementation of yolov9 loss
|
148 |
-
- `class` DualLoss: a implementation of yolov9 loss with auxiliary detection head
|
|
|
7 |
You can change the model architecture simply by modifying the YAML configuration file. Here's how:
|
8 |
|
9 |
1. **Modify Architecture in Config:**
|
10 |
+
|
11 |
Navigate to your model's configuration file (typically formate like `yolo/config/model/v9-c.yaml`).
|
12 |
- Adjust the architecture settings under the `architecture` section. Ensure that every module you reference exists in `module.py`, or refer to the next section on how to add new modules.
|
13 |
|
|
|
40 |
1. **Create a New Module:**
|
41 |
|
42 |
Define a new class in `module.py` that inherits from `nn.Module`.
|
43 |
+
|
44 |
The constructor should accept `in_channels` as a parameter. Make sure to calculate `out_channels` based on your model's requirements or configure it through the YAML file using `args`.
|
45 |
|
46 |
```python
|
|
|
49 |
super().__init__()
|
50 |
self.module = # conv, bool, ...
|
51 |
def forward(self, x):
|
52 |
+
return self.module(x)
|
53 |
```
|
54 |
|
55 |
2. **Reference in Config:**
|
|
|
138 |
- `func` draw_bboxes: given a image and list of bbox, draw bbox on the image
|
139 |
- `func` draw_model: visualize the given model
|
140 |
- **get_dataset**
|
141 |
+
- `func` download_file: for a given link, download the file
|
142 |
+
- `func` unzip_file: unzip the downloaded zip to data/
|
143 |
- `func` check_files: check if the dataset file numbers is correct
|
144 |
+
- `func` prepare_dataset: automatic download the dataset and check if it is correct
|
145 |
- **loss**
|
146 |
- `class` BoxLoss: a Custom Loss for bounding box
|
147 |
- `class` YOLOLoss: a implementation of yolov9 loss
|
148 |
+
- `class` DualLoss: a implementation of yolov9 loss with auxiliary detection head
|
pyproject.toml
CHANGED
@@ -31,4 +31,4 @@ requires = [
|
|
31 |
]
|
32 |
|
33 |
[project.scripts]
|
34 |
-
yolo = "yolo.lazy:main"
|
|
|
31 |
]
|
32 |
|
33 |
[project.scripts]
|
34 |
+
yolo = "yolo.lazy:main"
|
requirements.txt
CHANGED
@@ -12,4 +12,4 @@ rich
|
|
12 |
torch
|
13 |
torchvision
|
14 |
tqdm
|
15 |
-
wandb
|
|
|
12 |
torch
|
13 |
torchvision
|
14 |
tqdm
|
15 |
+
wandb
|
tests/test_model/test_yolo.py
CHANGED
@@ -20,7 +20,7 @@ def test_build_model():
|
|
20 |
|
21 |
OmegaConf.set_struct(cfg.model, False)
|
22 |
cfg.weight = None
|
23 |
-
model = YOLO(cfg.model
|
24 |
assert len(model.model) == 38
|
25 |
|
26 |
|
|
|
20 |
|
21 |
OmegaConf.set_struct(cfg.model, False)
|
22 |
cfg.weight = None
|
23 |
+
model = YOLO(cfg.model)
|
24 |
assert len(model.model) == 38
|
25 |
|
26 |
|
yolo/config/config.yaml
CHANGED
@@ -10,4 +10,3 @@ defaults:
|
|
10 |
- dataset: coco
|
11 |
- model: v9-c
|
12 |
- general
|
13 |
-
|
|
|
10 |
- dataset: coco
|
11 |
- model: v9-c
|
12 |
- general
|
|
yolo/config/dataset/coco.yaml
CHANGED
@@ -8,7 +8,7 @@ auto_download:
|
|
8 |
train2017:
|
9 |
file_name: train2017
|
10 |
file_num: 118287
|
11 |
-
val2017:
|
12 |
file_name: val2017
|
13 |
file_num: 5000
|
14 |
test2017:
|
@@ -17,4 +17,4 @@ auto_download:
|
|
17 |
annotations:
|
18 |
base_url: http://images.cocodataset.org/annotations/
|
19 |
annotations:
|
20 |
-
file_name: annotations_trainval2017
|
|
|
8 |
train2017:
|
9 |
file_name: train2017
|
10 |
file_num: 118287
|
11 |
+
val2017:
|
12 |
file_name: val2017
|
13 |
file_num: 5000
|
14 |
test2017:
|
|
|
17 |
annotations:
|
18 |
base_url: http://images.cocodataset.org/annotations/
|
19 |
annotations:
|
20 |
+
file_name: annotations_trainval2017
|
yolo/config/dataset/dev.yaml
CHANGED
@@ -2,4 +2,4 @@ path: data/dev
|
|
2 |
train: train
|
3 |
validation: test
|
4 |
|
5 |
-
auto_download:
|
|
|
2 |
train: train
|
3 |
validation: test
|
4 |
|
5 |
+
auto_download:
|
yolo/config/general.yaml
CHANGED
@@ -12,4 +12,4 @@ lucky_number: 10
|
|
12 |
use_wandb: False
|
13 |
use_TensorBoard: False
|
14 |
|
15 |
-
weight: weights/v9-c.pt
|
|
|
12 |
use_wandb: False
|
13 |
use_TensorBoard: False
|
14 |
|
15 |
+
weight: weights/v9-c.pt
|
yolo/config/model/v7-base.yaml
CHANGED
@@ -4,243 +4,243 @@ anchor:
|
|
4 |
|
5 |
model:
|
6 |
backbone:
|
7 |
-
- Conv:
|
8 |
args: {out_channels: 32, kernel_size: 3}
|
9 |
-
- Conv:
|
10 |
args: {out_channels: 64, kernel_size: 3, stride: 2}
|
11 |
-
- Conv:
|
12 |
args: {out_channels: 64, kernel_size: 3}
|
13 |
-
- Conv:
|
14 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
15 |
-
- Conv:
|
16 |
args: {out_channels: 64, kernel_size: 1}
|
17 |
-
- Conv:
|
18 |
args: {out_channels: 64, kernel_size: 1}
|
19 |
source: -2
|
20 |
-
- Conv:
|
21 |
args: {out_channels: 64, kernel_size: 3}
|
22 |
-
- Conv:
|
23 |
args: {out_channels: 64, kernel_size: 3}
|
24 |
-
- Conv:
|
25 |
args: {out_channels: 64, kernel_size: 3}
|
26 |
-
- Conv:
|
27 |
args: {out_channels: 64, kernel_size: 3}
|
28 |
-
- Concat:
|
29 |
source: [-1, -3, -5, -6]
|
30 |
-
- Conv:
|
31 |
args: {out_channels: 256, kernel_size: 1}
|
32 |
-
- Pool:
|
33 |
args: {padding: 0}
|
34 |
-
- Conv:
|
35 |
args: {out_channels: 128, kernel_size: 1}
|
36 |
-
- Conv:
|
37 |
args: {out_channels: 128, kernel_size: 1}
|
38 |
source: -3
|
39 |
-
- Conv:
|
40 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
41 |
-
- Concat:
|
42 |
source: [-1, -3]
|
43 |
-
- Conv:
|
44 |
args: {out_channels: 128, kernel_size: 1}
|
45 |
-
- Conv:
|
46 |
args: {out_channels: 128, kernel_size: 1}
|
47 |
source: -2
|
48 |
-
- Conv:
|
49 |
args: {out_channels: 128, kernel_size: 3}
|
50 |
-
- Conv:
|
51 |
args: {out_channels: 128, kernel_size: 3}
|
52 |
-
- Conv:
|
53 |
args: {out_channels: 128, kernel_size: 3}
|
54 |
-
- Conv:
|
55 |
args: {out_channels: 128, kernel_size: 3}
|
56 |
-
- Concat:
|
57 |
source: [-1, -3, -5, -6]
|
58 |
tags: 8x
|
59 |
-
- Conv:
|
60 |
args: {out_channels: 512, kernel_size: 1}
|
61 |
-
- Pool:
|
62 |
args: {padding: 0}
|
63 |
-
- Conv:
|
64 |
args: {out_channels: 256, kernel_size: 1}
|
65 |
-
- Conv:
|
66 |
args: {out_channels: 256, kernel_size: 1}
|
67 |
source: -3
|
68 |
-
- Conv:
|
69 |
args: {out_channels: 256, kernel_size: 3, stride: 2}
|
70 |
-
- Concat:
|
71 |
source: [-1, -3]
|
72 |
-
- Conv:
|
73 |
args: {out_channels: 256, kernel_size: 1}
|
74 |
-
- Conv:
|
75 |
args: {out_channels: 256, kernel_size: 1}
|
76 |
source: -2
|
77 |
-
- Conv:
|
78 |
args: {out_channels: 256, kernel_size: 3}
|
79 |
-
- Conv:
|
80 |
args: {out_channels: 256, kernel_size: 3}
|
81 |
-
- Conv:
|
82 |
args: {out_channels: 256, kernel_size: 3}
|
83 |
-
- Conv:
|
84 |
args: {out_channels: 256, kernel_size: 3}
|
85 |
-
- Concat:
|
86 |
source: [-1, -3, -5, -6]
|
87 |
-
- Conv:
|
88 |
args: {out_channels: 1024, kernel_size: 1}
|
89 |
tags: 16x
|
90 |
-
- Pool:
|
91 |
args: {padding: 0}
|
92 |
-
- Conv:
|
93 |
args: {out_channels: 512, kernel_size: 1}
|
94 |
-
- Conv:
|
95 |
args: {out_channels: 512, kernel_size: 1}
|
96 |
source: -3
|
97 |
-
- Conv:
|
98 |
args: {out_channels: 512, kernel_size: 3, stride: 2}
|
99 |
-
- Concat:
|
100 |
source: [-1, -3]
|
101 |
-
- Conv:
|
102 |
args: {out_channels: 256, kernel_size: 1}
|
103 |
-
- Conv:
|
104 |
args: {out_channels: 256, kernel_size: 1}
|
105 |
source: -2
|
106 |
-
- Conv:
|
107 |
args: {out_channels: 256, kernel_size: 3}
|
108 |
-
- Conv:
|
109 |
args: {out_channels: 256, kernel_size: 3}
|
110 |
-
- Conv:
|
111 |
args: {out_channels: 256, kernel_size: 3}
|
112 |
-
- Conv:
|
113 |
args: {out_channels: 256, kernel_size: 3}
|
114 |
-
- Concat:
|
115 |
source: [-1, -3, -5, -6]
|
116 |
-
- Conv:
|
117 |
args: {out_channels: 1024, kernel_size: 1}
|
118 |
tags: 32x
|
119 |
head:
|
120 |
-
- SPPCSPConv:
|
121 |
args: {out_channels: 512}
|
122 |
-
- Conv:
|
123 |
args: {out_channels: 256, kernel_size: 1}
|
124 |
-
- UpSample:
|
125 |
args: {scale_factor: 2}
|
126 |
-
- Conv:
|
127 |
args: {out_channels: 256, kernel_size: 1}
|
128 |
source: 16x
|
129 |
-
- Concat:
|
130 |
source: [-1, -2]
|
131 |
-
- Conv:
|
132 |
args: {out_channels: 256, kernel_size: 1}
|
133 |
-
- Conv:
|
134 |
args: {out_channels: 256, kernel_size: 1}
|
135 |
source: -2
|
136 |
-
- Conv:
|
137 |
args: {out_channels: 128, kernel_size: 3}
|
138 |
-
- Conv:
|
139 |
args: {out_channels: 128, kernel_size: 3}
|
140 |
-
- Conv:
|
141 |
args: {out_channels: 128, kernel_size: 3}
|
142 |
-
- Conv:
|
143 |
args: {out_channels: 128, kernel_size: 3}
|
144 |
-
- Concat:
|
145 |
source: [-1, -2, -3, -4, -5, -6]
|
146 |
-
- Conv:
|
147 |
args: {out_channels: 256, kernel_size: 1}
|
148 |
-
- Conv:
|
149 |
args: {out_channels: 128, kernel_size: 1}
|
150 |
-
- UpSample:
|
151 |
args: {scale_factor: 2}
|
152 |
-
- Conv:
|
153 |
args: {out_channels: 128, kernel_size: 1}
|
154 |
source: 8x
|
155 |
-
- Concat:
|
156 |
source: [-1, -2]
|
157 |
-
- Conv:
|
158 |
args: {out_channels: 128, kernel_size: 1}
|
159 |
-
- Conv:
|
160 |
args: {out_channels: 128, kernel_size: 1}
|
161 |
source: -2
|
162 |
-
- Conv:
|
163 |
args: {out_channels: 64, kernel_size: 3}
|
164 |
-
- Conv:
|
165 |
args: {out_channels: 64, kernel_size: 3}
|
166 |
-
- Conv:
|
167 |
args: {out_channels: 64, kernel_size: 3}
|
168 |
-
- Conv:
|
169 |
args: {out_channels: 64, kernel_size: 3}
|
170 |
-
- Concat:
|
171 |
source: [-1, -2, -3, -4, -5, -6]
|
172 |
-
- Conv:
|
173 |
args: {out_channels: 128, kernel_size: 1}
|
174 |
-
- Pool:
|
175 |
args: {padding: 0}
|
176 |
-
- Conv:
|
177 |
args: {out_channels: 128, kernel_size: 1}
|
178 |
-
- Conv:
|
179 |
args: {out_channels: 128, kernel_size: 1}
|
180 |
source: -3
|
181 |
-
- Conv:
|
182 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
183 |
-
- Concat:
|
184 |
source: [-1, -3, 63]
|
185 |
-
- Conv:
|
186 |
args: {out_channels: 256, kernel_size: 1}
|
187 |
-
- Conv:
|
188 |
args: {out_channels: 256, kernel_size: 1}
|
189 |
source: -2
|
190 |
-
- Conv:
|
191 |
args: {out_channels: 128, kernel_size: 3}
|
192 |
-
- Conv:
|
193 |
args: {out_channels: 128, kernel_size: 3}
|
194 |
-
- Conv:
|
195 |
args: {out_channels: 128, kernel_size: 3}
|
196 |
-
- Conv:
|
197 |
args: {out_channels: 128, kernel_size: 3}
|
198 |
-
- Concat:
|
199 |
source: [-1, -2, -3, -4, -5, -6]
|
200 |
-
- Conv:
|
201 |
args: {out_channels: 256, kernel_size: 1}
|
202 |
-
- Pool:
|
203 |
args: {padding: 0}
|
204 |
-
- Conv:
|
205 |
args: {out_channels: 256, kernel_size: 1}
|
206 |
-
- Conv:
|
207 |
args: {out_channels: 256, kernel_size: 1}
|
208 |
source: -3
|
209 |
-
- Conv:
|
210 |
args: {out_channels: 256, kernel_size: 3, stride: 2}
|
211 |
-
- Concat:
|
212 |
source: [-1, -3, 51]
|
213 |
-
- Conv:
|
214 |
args: {out_channels: 512, kernel_size: 1}
|
215 |
-
- Conv:
|
216 |
args: {out_channels: 512, kernel_size: 1}
|
217 |
source: -2
|
218 |
-
- Conv:
|
219 |
args: {out_channels: 256, kernel_size: 3}
|
220 |
-
- Conv:
|
221 |
args: {out_channels: 256, kernel_size: 3}
|
222 |
-
- Conv:
|
223 |
args: {out_channels: 256, kernel_size: 3}
|
224 |
-
- Conv:
|
225 |
args: {out_channels: 256, kernel_size: 3}
|
226 |
-
- Concat:
|
227 |
source: [-1, -2, -3, -4, -5, -6]
|
228 |
-
- Conv:
|
229 |
args: {out_channels: 512, kernel_size: 1}
|
230 |
-
- RepConv:
|
231 |
args: {out_channels: 256}
|
232 |
source: 75
|
233 |
-
- RepConv:
|
234 |
args: {out_channels: 512}
|
235 |
source: 88
|
236 |
-
- RepConv:
|
237 |
args: {out_channels: 1024}
|
238 |
source: 101
|
239 |
-
- IDetect:
|
240 |
args:
|
241 |
anchors:
|
242 |
- [12,16, 19,36, 40,28] # P3/8
|
243 |
- [36,75, 76,55, 72,146] # P4/16
|
244 |
- [142,110, 192,243, 459,401] # P5/32
|
245 |
source: [102, 103, 104]
|
246 |
-
output: True
|
|
|
4 |
|
5 |
model:
|
6 |
backbone:
|
7 |
+
- Conv:
|
8 |
args: {out_channels: 32, kernel_size: 3}
|
9 |
+
- Conv:
|
10 |
args: {out_channels: 64, kernel_size: 3, stride: 2}
|
11 |
+
- Conv:
|
12 |
args: {out_channels: 64, kernel_size: 3}
|
13 |
+
- Conv:
|
14 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
15 |
+
- Conv:
|
16 |
args: {out_channels: 64, kernel_size: 1}
|
17 |
+
- Conv:
|
18 |
args: {out_channels: 64, kernel_size: 1}
|
19 |
source: -2
|
20 |
+
- Conv:
|
21 |
args: {out_channels: 64, kernel_size: 3}
|
22 |
+
- Conv:
|
23 |
args: {out_channels: 64, kernel_size: 3}
|
24 |
+
- Conv:
|
25 |
args: {out_channels: 64, kernel_size: 3}
|
26 |
+
- Conv:
|
27 |
args: {out_channels: 64, kernel_size: 3}
|
28 |
+
- Concat:
|
29 |
source: [-1, -3, -5, -6]
|
30 |
+
- Conv:
|
31 |
args: {out_channels: 256, kernel_size: 1}
|
32 |
+
- Pool:
|
33 |
args: {padding: 0}
|
34 |
+
- Conv:
|
35 |
args: {out_channels: 128, kernel_size: 1}
|
36 |
+
- Conv:
|
37 |
args: {out_channels: 128, kernel_size: 1}
|
38 |
source: -3
|
39 |
+
- Conv:
|
40 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
41 |
+
- Concat:
|
42 |
source: [-1, -3]
|
43 |
+
- Conv:
|
44 |
args: {out_channels: 128, kernel_size: 1}
|
45 |
+
- Conv:
|
46 |
args: {out_channels: 128, kernel_size: 1}
|
47 |
source: -2
|
48 |
+
- Conv:
|
49 |
args: {out_channels: 128, kernel_size: 3}
|
50 |
+
- Conv:
|
51 |
args: {out_channels: 128, kernel_size: 3}
|
52 |
+
- Conv:
|
53 |
args: {out_channels: 128, kernel_size: 3}
|
54 |
+
- Conv:
|
55 |
args: {out_channels: 128, kernel_size: 3}
|
56 |
+
- Concat:
|
57 |
source: [-1, -3, -5, -6]
|
58 |
tags: 8x
|
59 |
+
- Conv:
|
60 |
args: {out_channels: 512, kernel_size: 1}
|
61 |
+
- Pool:
|
62 |
args: {padding: 0}
|
63 |
+
- Conv:
|
64 |
args: {out_channels: 256, kernel_size: 1}
|
65 |
+
- Conv:
|
66 |
args: {out_channels: 256, kernel_size: 1}
|
67 |
source: -3
|
68 |
+
- Conv:
|
69 |
args: {out_channels: 256, kernel_size: 3, stride: 2}
|
70 |
+
- Concat:
|
71 |
source: [-1, -3]
|
72 |
+
- Conv:
|
73 |
args: {out_channels: 256, kernel_size: 1}
|
74 |
+
- Conv:
|
75 |
args: {out_channels: 256, kernel_size: 1}
|
76 |
source: -2
|
77 |
+
- Conv:
|
78 |
args: {out_channels: 256, kernel_size: 3}
|
79 |
+
- Conv:
|
80 |
args: {out_channels: 256, kernel_size: 3}
|
81 |
+
- Conv:
|
82 |
args: {out_channels: 256, kernel_size: 3}
|
83 |
+
- Conv:
|
84 |
args: {out_channels: 256, kernel_size: 3}
|
85 |
+
- Concat:
|
86 |
source: [-1, -3, -5, -6]
|
87 |
+
- Conv:
|
88 |
args: {out_channels: 1024, kernel_size: 1}
|
89 |
tags: 16x
|
90 |
+
- Pool:
|
91 |
args: {padding: 0}
|
92 |
+
- Conv:
|
93 |
args: {out_channels: 512, kernel_size: 1}
|
94 |
+
- Conv:
|
95 |
args: {out_channels: 512, kernel_size: 1}
|
96 |
source: -3
|
97 |
+
- Conv:
|
98 |
args: {out_channels: 512, kernel_size: 3, stride: 2}
|
99 |
+
- Concat:
|
100 |
source: [-1, -3]
|
101 |
+
- Conv:
|
102 |
args: {out_channels: 256, kernel_size: 1}
|
103 |
+
- Conv:
|
104 |
args: {out_channels: 256, kernel_size: 1}
|
105 |
source: -2
|
106 |
+
- Conv:
|
107 |
args: {out_channels: 256, kernel_size: 3}
|
108 |
+
- Conv:
|
109 |
args: {out_channels: 256, kernel_size: 3}
|
110 |
+
- Conv:
|
111 |
args: {out_channels: 256, kernel_size: 3}
|
112 |
+
- Conv:
|
113 |
args: {out_channels: 256, kernel_size: 3}
|
114 |
+
- Concat:
|
115 |
source: [-1, -3, -5, -6]
|
116 |
+
- Conv:
|
117 |
args: {out_channels: 1024, kernel_size: 1}
|
118 |
tags: 32x
|
119 |
head:
|
120 |
+
- SPPCSPConv:
|
121 |
args: {out_channels: 512}
|
122 |
+
- Conv:
|
123 |
args: {out_channels: 256, kernel_size: 1}
|
124 |
+
- UpSample:
|
125 |
args: {scale_factor: 2}
|
126 |
+
- Conv:
|
127 |
args: {out_channels: 256, kernel_size: 1}
|
128 |
source: 16x
|
129 |
+
- Concat:
|
130 |
source: [-1, -2]
|
131 |
+
- Conv:
|
132 |
args: {out_channels: 256, kernel_size: 1}
|
133 |
+
- Conv:
|
134 |
args: {out_channels: 256, kernel_size: 1}
|
135 |
source: -2
|
136 |
+
- Conv:
|
137 |
args: {out_channels: 128, kernel_size: 3}
|
138 |
+
- Conv:
|
139 |
args: {out_channels: 128, kernel_size: 3}
|
140 |
+
- Conv:
|
141 |
args: {out_channels: 128, kernel_size: 3}
|
142 |
+
- Conv:
|
143 |
args: {out_channels: 128, kernel_size: 3}
|
144 |
+
- Concat:
|
145 |
source: [-1, -2, -3, -4, -5, -6]
|
146 |
+
- Conv:
|
147 |
args: {out_channels: 256, kernel_size: 1}
|
148 |
+
- Conv:
|
149 |
args: {out_channels: 128, kernel_size: 1}
|
150 |
+
- UpSample:
|
151 |
args: {scale_factor: 2}
|
152 |
+
- Conv:
|
153 |
args: {out_channels: 128, kernel_size: 1}
|
154 |
source: 8x
|
155 |
+
- Concat:
|
156 |
source: [-1, -2]
|
157 |
+
- Conv:
|
158 |
args: {out_channels: 128, kernel_size: 1}
|
159 |
+
- Conv:
|
160 |
args: {out_channels: 128, kernel_size: 1}
|
161 |
source: -2
|
162 |
+
- Conv:
|
163 |
args: {out_channels: 64, kernel_size: 3}
|
164 |
+
- Conv:
|
165 |
args: {out_channels: 64, kernel_size: 3}
|
166 |
+
- Conv:
|
167 |
args: {out_channels: 64, kernel_size: 3}
|
168 |
+
- Conv:
|
169 |
args: {out_channels: 64, kernel_size: 3}
|
170 |
+
- Concat:
|
171 |
source: [-1, -2, -3, -4, -5, -6]
|
172 |
+
- Conv:
|
173 |
args: {out_channels: 128, kernel_size: 1}
|
174 |
+
- Pool:
|
175 |
args: {padding: 0}
|
176 |
+
- Conv:
|
177 |
args: {out_channels: 128, kernel_size: 1}
|
178 |
+
- Conv:
|
179 |
args: {out_channels: 128, kernel_size: 1}
|
180 |
source: -3
|
181 |
+
- Conv:
|
182 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
183 |
+
- Concat:
|
184 |
source: [-1, -3, 63]
|
185 |
+
- Conv:
|
186 |
args: {out_channels: 256, kernel_size: 1}
|
187 |
+
- Conv:
|
188 |
args: {out_channels: 256, kernel_size: 1}
|
189 |
source: -2
|
190 |
+
- Conv:
|
191 |
args: {out_channels: 128, kernel_size: 3}
|
192 |
+
- Conv:
|
193 |
args: {out_channels: 128, kernel_size: 3}
|
194 |
+
- Conv:
|
195 |
args: {out_channels: 128, kernel_size: 3}
|
196 |
+
- Conv:
|
197 |
args: {out_channels: 128, kernel_size: 3}
|
198 |
+
- Concat:
|
199 |
source: [-1, -2, -3, -4, -5, -6]
|
200 |
+
- Conv:
|
201 |
args: {out_channels: 256, kernel_size: 1}
|
202 |
+
- Pool:
|
203 |
args: {padding: 0}
|
204 |
+
- Conv:
|
205 |
args: {out_channels: 256, kernel_size: 1}
|
206 |
+
- Conv:
|
207 |
args: {out_channels: 256, kernel_size: 1}
|
208 |
source: -3
|
209 |
+
- Conv:
|
210 |
args: {out_channels: 256, kernel_size: 3, stride: 2}
|
211 |
+
- Concat:
|
212 |
source: [-1, -3, 51]
|
213 |
+
- Conv:
|
214 |
args: {out_channels: 512, kernel_size: 1}
|
215 |
+
- Conv:
|
216 |
args: {out_channels: 512, kernel_size: 1}
|
217 |
source: -2
|
218 |
+
- Conv:
|
219 |
args: {out_channels: 256, kernel_size: 3}
|
220 |
+
- Conv:
|
221 |
args: {out_channels: 256, kernel_size: 3}
|
222 |
+
- Conv:
|
223 |
args: {out_channels: 256, kernel_size: 3}
|
224 |
+
- Conv:
|
225 |
args: {out_channels: 256, kernel_size: 3}
|
226 |
+
- Concat:
|
227 |
source: [-1, -2, -3, -4, -5, -6]
|
228 |
+
- Conv:
|
229 |
args: {out_channels: 512, kernel_size: 1}
|
230 |
+
- RepConv:
|
231 |
args: {out_channels: 256}
|
232 |
source: 75
|
233 |
+
- RepConv:
|
234 |
args: {out_channels: 512}
|
235 |
source: 88
|
236 |
+
- RepConv:
|
237 |
args: {out_channels: 1024}
|
238 |
source: 101
|
239 |
+
- IDetect:
|
240 |
args:
|
241 |
anchors:
|
242 |
- [12,16, 19,36, 40,28] # P3/8
|
243 |
- [36,75, 76,55, 72,146] # P4/16
|
244 |
- [142,110, 192,243, 459,401] # P5/32
|
245 |
source: [102, 103, 104]
|
246 |
+
output: True
|
yolo/config/model/v9-c.yaml
CHANGED
@@ -13,7 +13,7 @@ model:
|
|
13 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
14 |
- RepNCSPELAN:
|
15 |
args: {out_channels: 256, part_channels: 128}
|
16 |
-
|
17 |
- ADown:
|
18 |
args: {out_channels: 256}
|
19 |
- RepNCSPELAN:
|
@@ -25,13 +25,13 @@ model:
|
|
25 |
- RepNCSPELAN:
|
26 |
args: {out_channels: 512, part_channels: 512}
|
27 |
tags: B4
|
28 |
-
|
29 |
- ADown:
|
30 |
args: {out_channels: 512}
|
31 |
- RepNCSPELAN:
|
32 |
args: {out_channels: 512, part_channels: 512}
|
33 |
tags: B5
|
34 |
-
|
35 |
neck:
|
36 |
- SPPELAN:
|
37 |
args: {out_channels: 512}
|
@@ -49,12 +49,12 @@ model:
|
|
49 |
args: {scale_factor: 2, mode: nearest}
|
50 |
- Concat:
|
51 |
source: [-1, B3]
|
52 |
-
|
53 |
head:
|
54 |
- RepNCSPELAN:
|
55 |
args: {out_channels: 256, part_channels: 256}
|
56 |
tags: P3
|
57 |
-
|
58 |
- ADown:
|
59 |
args: {out_channels: 256}
|
60 |
- Concat:
|
@@ -70,7 +70,7 @@ model:
|
|
70 |
- RepNCSPELAN:
|
71 |
args: {out_channels: 512, part_channels: 512}
|
72 |
tags: P5
|
73 |
-
|
74 |
auxiliary:
|
75 |
- CBLinear:
|
76 |
source: B3
|
@@ -84,7 +84,7 @@ model:
|
|
84 |
source: B5
|
85 |
args: {out_channels: [256, 512, 512]}
|
86 |
tags: R5
|
87 |
-
|
88 |
- Conv:
|
89 |
args: {out_channels: 64, kernel_size: 3, stride: 2}
|
90 |
source: 0
|
@@ -126,7 +126,7 @@ model:
|
|
126 |
- Anchor2Box:
|
127 |
source: aux_head
|
128 |
output: True
|
129 |
-
args:
|
130 |
reg_max: ${model.anchor.reg_max}
|
131 |
strides: ${model.anchor.strides}
|
132 |
tags: aux_bbox
|
@@ -138,7 +138,7 @@ model:
|
|
138 |
- Anchor2Box:
|
139 |
source: reg_head
|
140 |
output: True
|
141 |
-
args:
|
142 |
reg_max: ${model.anchor.reg_max}
|
143 |
strides: ${model.anchor.strides}
|
144 |
-
tags: reg_bbox
|
|
|
13 |
args: {out_channels: 128, kernel_size: 3, stride: 2}
|
14 |
- RepNCSPELAN:
|
15 |
args: {out_channels: 256, part_channels: 128}
|
16 |
+
|
17 |
- ADown:
|
18 |
args: {out_channels: 256}
|
19 |
- RepNCSPELAN:
|
|
|
25 |
- RepNCSPELAN:
|
26 |
args: {out_channels: 512, part_channels: 512}
|
27 |
tags: B4
|
28 |
+
|
29 |
- ADown:
|
30 |
args: {out_channels: 512}
|
31 |
- RepNCSPELAN:
|
32 |
args: {out_channels: 512, part_channels: 512}
|
33 |
tags: B5
|
34 |
+
|
35 |
neck:
|
36 |
- SPPELAN:
|
37 |
args: {out_channels: 512}
|
|
|
49 |
args: {scale_factor: 2, mode: nearest}
|
50 |
- Concat:
|
51 |
source: [-1, B3]
|
52 |
+
|
53 |
head:
|
54 |
- RepNCSPELAN:
|
55 |
args: {out_channels: 256, part_channels: 256}
|
56 |
tags: P3
|
57 |
+
|
58 |
- ADown:
|
59 |
args: {out_channels: 256}
|
60 |
- Concat:
|
|
|
70 |
- RepNCSPELAN:
|
71 |
args: {out_channels: 512, part_channels: 512}
|
72 |
tags: P5
|
73 |
+
|
74 |
auxiliary:
|
75 |
- CBLinear:
|
76 |
source: B3
|
|
|
84 |
source: B5
|
85 |
args: {out_channels: [256, 512, 512]}
|
86 |
tags: R5
|
87 |
+
|
88 |
- Conv:
|
89 |
args: {out_channels: 64, kernel_size: 3, stride: 2}
|
90 |
source: 0
|
|
|
126 |
- Anchor2Box:
|
127 |
source: aux_head
|
128 |
output: True
|
129 |
+
args:
|
130 |
reg_max: ${model.anchor.reg_max}
|
131 |
strides: ${model.anchor.strides}
|
132 |
tags: aux_bbox
|
|
|
138 |
- Anchor2Box:
|
139 |
source: reg_head
|
140 |
output: True
|
141 |
+
args:
|
142 |
reg_max: ${model.anchor.reg_max}
|
143 |
strides: ${model.anchor.strides}
|
144 |
+
tags: reg_bbox
|
yolo/config/task/inference.yaml
CHANGED
@@ -7,4 +7,4 @@ data:
|
|
7 |
data_augment: {}
|
8 |
nms:
|
9 |
min_confidence: 0.5
|
10 |
-
min_iou: 0.5
|
|
|
7 |
data_augment: {}
|
8 |
nms:
|
9 |
min_confidence: 0.5
|
10 |
+
min_iou: 0.5
|
yolo/config/task/train.yaml
CHANGED
@@ -6,7 +6,7 @@ defaults:
|
|
6 |
epoch: 500
|
7 |
|
8 |
data:
|
9 |
-
batch_size: 16
|
10 |
image_size: ${image_size}
|
11 |
cpu_num: ${cpu_num}
|
12 |
shuffle: True
|
@@ -26,7 +26,7 @@ optimizer:
|
|
26 |
loss:
|
27 |
objective:
|
28 |
BCELoss: 0.5
|
29 |
-
BoxLoss: 7.5
|
30 |
DFLoss: 1.5
|
31 |
aux:
|
32 |
0.25
|
|
|
6 |
epoch: 500
|
7 |
|
8 |
data:
|
9 |
+
batch_size: 16
|
10 |
image_size: ${image_size}
|
11 |
cpu_num: ${cpu_num}
|
12 |
shuffle: True
|
|
|
26 |
loss:
|
27 |
objective:
|
28 |
BCELoss: 0.5
|
29 |
+
BoxLoss: 7.5
|
30 |
DFLoss: 1.5
|
31 |
aux:
|
32 |
0.25
|
yolo/config/task/validation.yaml
CHANGED
@@ -9,4 +9,4 @@ data:
|
|
9 |
data_augment: {}
|
10 |
nms:
|
11 |
min_confidence: 0.001
|
12 |
-
min_iou: 0.7
|
|
|
9 |
data_augment: {}
|
10 |
nms:
|
11 |
min_confidence: 0.001
|
12 |
+
min_iou: 0.7
|
yolo/tools/data_augmentation.py
CHANGED
@@ -7,8 +7,9 @@ from torchvision.transforms import functional as TF
|
|
7 |
class AugmentationComposer:
|
8 |
"""Composes several transforms together."""
|
9 |
|
10 |
-
def __init__(self, transforms, image_size: int = 640):
|
11 |
self.transforms = transforms
|
|
|
12 |
self.image_size = image_size[0]
|
13 |
self.pad_resize = PadAndResize(self.image_size)
|
14 |
|
@@ -38,10 +39,10 @@ class PadAndResize:
|
|
38 |
|
39 |
resized_img = square_img.resize((self.image_size, self.image_size))
|
40 |
|
41 |
-
boxes[:, 1] = (boxes[:, 1] + left) * scale
|
42 |
-
boxes[:, 2] = (boxes[:, 2] + top) * scale
|
43 |
-
boxes[:, 3] = (boxes[:, 3] + left) * scale
|
44 |
-
boxes[:, 4] = (boxes[:, 4] + top) * scale
|
45 |
|
46 |
return resized_img, boxes
|
47 |
|
|
|
7 |
class AugmentationComposer:
|
8 |
"""Composes several transforms together."""
|
9 |
|
10 |
+
def __init__(self, transforms, image_size: int = [640, 640]):
|
11 |
self.transforms = transforms
|
12 |
+
# TODO: handle List of image_size [640, 640]
|
13 |
self.image_size = image_size[0]
|
14 |
self.pad_resize = PadAndResize(self.image_size)
|
15 |
|
|
|
39 |
|
40 |
resized_img = square_img.resize((self.image_size, self.image_size))
|
41 |
|
42 |
+
boxes[:, 1] = (boxes[:, 1] * image.width + left) / self.image_size * scale
|
43 |
+
boxes[:, 2] = (boxes[:, 2] * image.height + top) / self.image_size * scale
|
44 |
+
boxes[:, 3] = (boxes[:, 3] * image.width + left) / self.image_size * scale
|
45 |
+
boxes[:, 4] = (boxes[:, 4] * image.height + top) / self.image_size * scale
|
46 |
|
47 |
return resized_img, boxes
|
48 |
|
yolo/utils/logging_utils.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
"""
|
2 |
-
Module for initializing logging tools used in machine learning and data processing.
|
3 |
-
Supports integration with Weights & Biases (wandb), Loguru, TensorBoard, and other
|
4 |
logging frameworks as needed.
|
5 |
|
6 |
-
This setup ensures consistent logging across various platforms, facilitating
|
7 |
effective monitoring and debugging.
|
8 |
|
9 |
Example:
|
|
|
1 |
"""
|
2 |
+
Module for initializing logging tools used in machine learning and data processing.
|
3 |
+
Supports integration with Weights & Biases (wandb), Loguru, TensorBoard, and other
|
4 |
logging frameworks as needed.
|
5 |
|
6 |
+
This setup ensures consistent logging across various platforms, facilitating
|
7 |
effective monitoring and debugging.
|
8 |
|
9 |
Example:
|