henry000 commited on
Commit
836aebe
·
1 Parent(s): b86a654

📝 [Update] README document

Browse files
Files changed (4) hide show
  1. README.md +56 -51
  2. docs/CONTRIBUTING.md +44 -0
  3. docs/HOWTO.md +90 -0
  4. docs/MODELS.md +31 -0
README.md CHANGED
@@ -1,5 +1,4 @@
1
- # YOLOv9-MIT
2
- An MIT license rewrite of YOLOv9
3
 
4
  ![WIP](https://img.shields.io/badge/status-WIP-orange)
5
  > [!IMPORTANT]
@@ -7,66 +6,72 @@ An MIT license rewrite of YOLOv9
7
  >
8
  > 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.
9
 
10
- ## Contributing
11
 
12
- While the project's structure is still being finalized, we ask that potential contributors wait for these foundational decisions to be made. We greatly appreciate your patience and are excited to welcome contributions from the community once we are ready. Alternatively, you are welcome to propose functions that should be implemented based on the original YOLO version or suggest other enhancements!
 
 
 
 
13
 
14
- If you are interested in contributing, please keep an eye on project updates or contact us directly at [[email protected]](mailto:[email protected]) for more information.
 
 
15
 
16
- # Installing Dependencies
17
- ```
 
 
 
18
  pip install -r requirements.txt
19
  ```
20
 
21
- # Training the Model
22
- To start training the model, use the following command:
23
- ```bash
24
- $python examples/example_train.py
25
  ```
26
- Ensure that you are in the root directory of the project when you run this command.
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- The training script will automatically utilize the configuration files from the `yolo/config/` directory as specified by the Hydra configuration framework. This setup allows easy management and adjustment of training parameters without modifying the code.
 
29
 
30
- To override any configuration parameters directly from the command line, you can specify them after the script. For example, to change the batch size, you can run:
 
31
 
32
- ```bash
33
- $python examples/example_train.py hyper.data.batch_size=8
34
  ```
35
 
 
36
 
 
 
37
 
38
- ## Star History
39
-
40
- [![Star History Chart](https://api.star-history.com/svg?repos=WongKinYiu/yolov9mit&type=Date)](https://star-history.com/#WongKinYiu/yolov9mit&Date)
41
-
42
- ## To-Do Lists
43
- - [ ] Project Setup
44
- - [X] requirements
45
- - [x] LICENSE
46
- - [ ] README
47
- - [x] pytests
48
- - [ ] setup.py/pip install
49
- - [x] log format
50
- - [ ] hugging face
51
- - [ ] Data proccess
52
- - [ ] Dataset
53
- - [x] Download script
54
- - [ ] Auto Download
55
- - [ ] xywh, xxyy, xcyc
56
- - [x] Dataloder
57
- - [x] Data arugment
58
- - [ ] Model
59
- - [ ] load model
60
- - [ ] from yaml
61
- - [ ] from github
62
- - [x] trainer
63
- - [x] train_one_iter
64
- - [x] train_one_epoch
65
- - [ ] DDP
66
- - [x] EMA, OTA
67
- - [ ] Loss
68
- - [ ] Run
69
- - [ ] train
70
- - [ ] test
71
- - [ ] demo
72
- - [x] Configuration
 
1
+ # YOLO: Official Implementation of YOLOv{7, 9}
 
2
 
3
  ![WIP](https://img.shields.io/badge/status-WIP-orange)
4
  > [!IMPORTANT]
 
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 the YOLOv7 and YOLOv9. This repository will contains the complete codebase, pre-trained models, and detailed instructions for training and deploying YOLOv9.
10
 
11
+ ## TL;DR
12
+ - Official YOLOv9 model implementation.
13
+ - Features real-time detection with state-of-the-art accuracy.
14
+ <!-- - Includes pre-trained models and training scripts. -->
15
+ - Quick train: `python examples/example_train.py`
16
 
17
+ ## Introduction
18
+ - [**YOLOv9**: Learning What You Want to Learn Using Programmable Gradient Information](https://arxiv.org/abs/2402.13616)
19
+ - [**YOLOv7**: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors](https://arxiv.org/abs/2207.02696)
20
 
21
+ ## Installation
22
+ To get started with YOLOv9, clone this repository and install the required dependencies:
23
+ ```shell
24
+ git clone [email protected]:WongKinYiu/yolov9mit.git
25
+ cd yolov9mit
26
  pip install -r requirements.txt
27
  ```
28
 
29
+ <!--
 
 
 
30
  ```
31
+ pip install git+https://github.com/WongKinYiu/yolov9mit.git
32
+ ```
33
+ -->
34
+
35
+ <!-- ### Quick Start
36
+ Run YOLOv9 on a pre-trained model with:
37
+
38
+ ```shell
39
+ python examples/example_train.py hyper.data.batch_size=8
40
+ ``` -->
41
+
42
+ <!-- ## Model Zoo[WIP]
43
+ Find pre-trained models with benchmarks on various datasets in the [Model Zoo](docs/MODELS). -->
44
 
45
+ ## Training
46
+ For training YOLOv9 on your dataset:
47
 
48
+ Modify the configuration file data/config.yaml to point to your dataset.
49
+ Run the training script:
50
 
51
+ ```shell
52
+ python examples/example_train.py hyper.data.batch_size=8 model=v9-c
53
  ```
54
 
55
+ More customization details, or ways to modify the model can be found [HOWTO](docs/HOWTO).
56
 
57
+ ## Evaluation [WIP]
58
+ Evaluate the model performance using:
59
 
60
+ ```shell
61
+ python examples/examples_evaluate.py weights=v9-c.pt
62
+ ```
63
+
64
+ ## Contributing
65
+ Contributions to the YOLOv9 project are welcome! See [CONTRIBUTING](docs/CONTRIBUTING.md) for how to help out.
66
+
67
+ ## Citations
68
+ ```
69
+ @misc{wang2024yolov9,
70
+ title={YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information},
71
+ author={Chien-Yao Wang and I-Hau Yeh and Hong-Yuan Mark Liao},
72
+ year={2024},
73
+ eprint={2402.13616},
74
+ archivePrefix={arXiv},
75
+ primaryClass={cs.CV}
76
+ }
77
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/CONTRIBUTING.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to YOLO
2
+
3
+ Thank you for your interest in contributing to this project! We value your contributions and want to make the process as easy and enjoyable as possible. Below you will find the guidelines for contributing.
4
+
5
+ ## Quick Links
6
+ - [Main README](../README.md)
7
+ - [License](../LICENSE)
8
+ - [Issue Tracker](https://github.com/WongKinYiu/yolov9mit/issues)
9
+ - [Pull Requests](https://github.com/WongKinYiu/yolov9mit/pulls)
10
+
11
+ ## Testing and Formatting
12
+ We strive to maintain a high standard of quality in our codebase:
13
+ - **Testing:** We use `pytest` for testing. Please add tests for new code you create.
14
+ - **Formatting:** Our code follows a consistent style enforced by `isort` for imports sorting and `black` for code formatting. Run these tools to format your code before submitting a pull request.
15
+
16
+ ## GitHub Actions
17
+ We utilize GitHub Actions for continuous integration. When you submit a pull request, automated tests and formatting checks will run. Ensure that these checks pass for your pull request to be accepted.
18
+
19
+ ## How to Contribute
20
+
21
+ ### Proposing Enhancements
22
+ For feature requests or improvements, open an issue with:
23
+ - A clear title and description.
24
+ - Explain why this enhancement would be useful.
25
+ - Considerations or potential implementation details.
26
+
27
+ ## Pull Request Checklist
28
+ Before sending your pull request, always check the following:
29
+ - The code follows the [Python style guide](https://www.python.org/dev/peps/pep-0008/).
30
+ - Code and files are well organized.
31
+ - All tests pass.
32
+ - New code is covered by tests.
33
+ - We would be very happy if [gitmoji😆](https://www.npmjs.com/package/gitmoji-cli) could be used to assist the commit message💬!
34
+
35
+ ## Code Review Process
36
+ Once you submit a PR, maintainers will review your work, suggest changes if necessary, and merge it once it’s approved.
37
+
38
+ ---
39
+
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
+
docs/HOWTO.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # How To modified YOLO
2
+
3
+ To facilitate easy customization of the YOLO model, we've structured the codebase to allow for changes through configuration files and minimal code adjustments. This guide will walk you through the steps to customize various components of the model including the architecture, blocks, data loaders, and loss functions.
4
+
5
+ ## Custom Model Architecture
6
+
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
+
14
+ ```yaml
15
+ model:
16
+ foo:
17
+ - ADown:
18
+ args: {out_channels: 256}
19
+ - RepNCSPELAN:
20
+ source: -2
21
+ args: {out_channels: 512, part_channels: 256}
22
+ tags: B4
23
+ bar:
24
+ - Concat:
25
+ source: [-2, B4]
26
+ ```
27
+
28
+ `tags`: Use this to labels any module you want, and could be the module source.
29
+
30
+ `source`: Set this to the index of the module output you wish to use as input; default is `-1` which refers to the last module's output. Capable tags, relative position, absolute position
31
+
32
+ `args`: A dictionary used to initialize parameters for convolutional or bottleneck layers.
33
+
34
+ `output`: Whether to serve as the output of the model.
35
+
36
+ ## Custom Block
37
+
38
+ To add or modify a block in the model:
39
+
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
47
+ class CustomBlock(nn.Module):
48
+ def __init__(self, in_channels, out_channels, **kwargs):
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:**
56
+ ```yaml
57
+ ...
58
+ - CustomBlock:
59
+ args: {out_channels: int, etc: ...}
60
+ ...
61
+ ...
62
+ ```
63
+
64
+
65
+ ## Custom Data Augmentation
66
+
67
+ Custom transformations should be designed to accept an image and its bounding boxes, and return them after applying the desired changes. Here’s how you can define such a transformation:
68
+
69
+
70
+ 1. **Define Dataset:**
71
+
72
+ Your class must have a `__call__` method that takes a PIL image and its corresponding bounding boxes as input, and returns them after processing.
73
+
74
+
75
+ ```python
76
+ class CustomTransform:
77
+ def __init__(self, prob=0.5):
78
+ self.prob = prob
79
+
80
+ def __call__(self, image, boxes):
81
+ return image, boxes
82
+ ```
83
+ 2. **Update CustomTransform in Config:**
84
+
85
+ Specify your custom transformation in a YAML config `yolo/config/data/augment.yaml`. For examples:
86
+ ```yaml
87
+ Mosaic: 1
88
+ # ... (Other Transform)
89
+ CustomTransform: 0.5
90
+ ```
docs/MODELS.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # YOLO Model Zoo
2
+
3
+ Welcome to the YOLOv9 Model Zoo! Here, you will find a variety of pre-trained models tailored to different use cases and performance needs. Each model comes with detailed information about its training regime, performance metrics, and usage instructions.
4
+
5
+ ## Standard Models
6
+
7
+ These models are trained on common datasets like COCO and provide a balance between speed and accuracy.
8
+
9
+
10
+ | Model | Test Size | AP<sup>val</sup> | AP<sub>50</sub><sup>val</sup> | AP<sub>75</sub><sup>val</sup> | Param. | FLOPs |
11
+ | :-- | :-: | :-: | :-: | :-: | :-: | :-: |
12
+ | [**YOLOv9-T**]() | 640 | **38.3%** | **53.1%** | **41.3%** | **2.0M** | **7.7G** |
13
+ | [**YOLOv9-S**]() | 640 | **46.8%** | **63.4%** | **50.7%** | **7.1M** | **26.4G** |
14
+ | [**YOLOv9-M**]() | 640 | **51.4%** | **68.1%** | **56.1%** | **20.0M** | **76.3G** |
15
+ | [**YOLOv9-C**]() | 640 | **53.0%** | **70.2%** | **57.8%** | **25.3M** | **102.1G** |
16
+ | [**YOLOv9-E**]() | 640 | **55.6%** | **72.8%** | **60.6%** | **57.3M** | **189.0G** |
17
+ | | | | | | | |
18
+ | [**YOLOv7**]() | 640 | **51.4%** | **69.7%** | **55.9%** |
19
+ | [**YOLOv7-X**]() | 640 | **53.1%** | **71.2%** | **57.8%** |
20
+ | [**YOLOv7-W6**]() | 1280 | **54.9%** | **72.6%** | **60.1%** |
21
+ | [**YOLOv7-E6**]() | 1280 | **56.0%** | **73.5%** | **61.2%** |
22
+ | [**YOLOv7-D6**]() | 1280 | **56.6%** | **74.0%** | **61.8%** |
23
+ | [**YOLOv7-E6E**]() | 1280 | **56.8%** | **74.4%** | **62.1%** |
24
+
25
+ ## Download and Usage Instructions
26
+
27
+ To use these models, download them from the links provided and use the following command to run detection:
28
+
29
+ ```bash
30
+ $yolo detect weights=path/to/model.pt img=640 conf=0.25 source=your_image.jpg
31
+ ```