Skip to content

Commit

Permalink
🔀 [Merge] branch 'SETUP'
Browse files Browse the repository at this point in the history
  • Loading branch information
henrytsui000 committed Jul 31, 2024
2 parents 1e4ec0a + d2fb889 commit fb4930b
Show file tree
Hide file tree
Showing 50 changed files with 1,197 additions and 112 deletions.
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

sphinx:
configuration: docs/conf.py

Expand Down
1 change: 0 additions & 1 deletion docs/0_get_start/0_quick_start.md

This file was deleted.

71 changes: 71 additions & 0 deletions docs/0_get_start/0_quick_start.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Quick Start
===========

.. note::
We expect all customizations to be done primarily by passing arguments or modifying the YAML config files.
If more detailed modifications are needed, custom content should be modularized as much as possible to avoid extensive code modifications.

.. _QuickInstallYOLO:

Install YOLO
------------

Clone the repository and install the dependencies:

.. code-block:: bash
git clone https://github.com/WongKinYiu/YOLO.git
cd YOLO
pip install -r requirements-dev.txt
# Make sure to work inside the cloned folder.
Alternatively, If you are planning to make a simple change:

**Note**: In the following examples, you should replace ``python yolo/lazy.py`` with ``yolo`` .

.. code-block:: bash
pip install git+https://github.com/WongKinYiu/YOLO.git
**Note**: Most tasks already include at yolo/lazy.py, so you can run with this prefix and follow arguments: ``python yolo/lazy.py``


Train Model
-----------

To train the model, use the following command:

.. code-block:: bash
python yolo/lazy.py task=train
yolo task=train # if installed via pip
- Overriding the ``dataset`` parameter, you can customize your dataset via a dataset config.
- Overriding YOLO model by setting the ``model`` parameter to ``{v9-c, v9-m, ...}``.
- More details can be found at :ref:`Train Tutorials<Train>`.

For example:

.. code-block:: bash
python yolo/lazy.py task=train dataset=AYamlFilePath model=v9-m
yolo task=train dataset=AYamlFilePath model=v9-m # if installed via pip
Inference & Deployment
------------------------

Inference is the default task of ``yolo/lazy.py``. To run inference and deploy the model, use:
More details can be found at :ref:`Inference Tutorials <Inference>`.

.. code-block:: bash
python yolo/lazy.py task.data.source=AnySource
yolo task.data.source=AnySource # if installed via pip
You can enable fast inference modes by adding the parameter ``task.fast_inference={onnx, trt, deploy}``.

- Theoretical acceleration following :ref:`YOLOv9 <Deploy>`.
- Hardware acceleration like :ref:`ONNX <ONNX>` and :ref:`TensorRT <TensorRT>`. for optimized deployment.
4 changes: 0 additions & 4 deletions docs/0_get_start/1_installations.md

This file was deleted.

66 changes: 66 additions & 0 deletions docs/0_get_start/1_introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
What is YOLO
============

``YOLO`` (You Only Look Once) is a state-of-the-art, real-time object detection system. It is designed to predict bounding boxes and class probabilities for objects in an image with high accuracy and speed. YOLO models, including the latest YOLOv9, are known for their efficiency in detecting objects in a single forward pass through the network, making them highly suitable for real-time applications.

YOLOv9 introduces improvements in both architecture and loss functions to enhance prediction accuracy and inference speed.

Forward Process
---------------

The forward process of YOLOv9 can be visualized as follows:

.. mermaid::

graph LR
subgraph YOLOv9
Auxiliary
AP["Auxiliary Prediction"]
end
BackBone-->FPN;
FPN-->PAN;
PAN-->MP["Main Prediction"];
BackBone-->Auxiliary;
Auxiliary-->AP;

- **BackBone**: Extracts features from the input image.
- **FPN (Feature Pyramid Network)**: Aggregates features at different scales.
- **PAN (Region Proposal Network)**: Proposes regions of interest.
- **Main Prediction**: The primary detection output.
- **Auxiliary Prediction**: Additional predictions to assist the main prediction.

Loss Function
-------------

The loss function of YOLOv9 combines several components to optimize the model's performance:

.. mermaid::

flowchart LR
gtb-->cls
gtb["Ground Truth"]-->iou
pdm-.->cls["Max Class"]
pdm["Main Prediction"]-.->iou["Closest IoU"]
pdm-.->anc["box in anchor"]
cls-->gt
iou-->gt["Matched GT Box"]
anc-.->gt

gt-->Liou["IoU Loss"]
pdm-->Liou
pdm-->Lbce
gt-->Lbce["BCE Loss"]
gt-->Ldfl["DFL Loss"]
pdm-->Ldfl

Lbce-->ML
Liou-->ML
Ldfl-->ML["Total Loss"]

- **Ground Truth**: The actual labels and bounding boxes in the dataset.
- **Main Prediction**: The model's predicted bounding boxes and class scores.
- **IoU (Intersection over Union)**: Measures the overlap between the predicted and ground truth boxes.
- **BCE (Binary Cross-Entropy) Loss**: Used for class prediction.
- **DFL (Distribution Focal Loss)**: Used for improving the precision of bounding box regression.

By optimizing these components, YOLOv9 aims to achieve high accuracy and robustness in object detection tasks.
3 changes: 0 additions & 3 deletions docs/0_get_start/2_git.md

This file was deleted.

101 changes: 101 additions & 0 deletions docs/0_get_start/2_installations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Install YOLO
============

This guide will help you set up YOLO on your machine.
We recommend starting with `GitHub Settings <#git-github>`_ for more flexible customization.
If you are planning to perform inference only or require a simple customization, you can choose to install via `PyPI <#pypi-pip-install>`_.

Torch Requirements
-------------------

The following table summarizes the torch requirements for different operating systems and hardware configurations:


.. tabs::

.. tab:: Linux

.. tabs::

.. tab:: CUDA

PyTorch: 1.12+

.. tab:: CPU

PyTorch: 1.12+

.. tab:: MacOS

.. tabs::

.. tab:: MPS

PyTorch: 2.2+
.. tab:: CPU
PyTorch: 2.2+
.. tab:: Windows

.. tabs::

.. tab:: CUDA

[WIP]

.. tab:: CPU

[WIP]


Git & GitHub
------------

First, Clone the repository:

.. code-block:: bash
git clone https://github.com/WongKinYiu/YOLO.git
Alternatively, you can directly download the repository via this `link <https://github.com/WongKinYiu/YOLO/archive/refs/heads/main.zip>`_.

Next, install the required packages:

.. code-block:: bash
# For the minimal requirements, use:
pip install -r requirements.txt
# For a full installation, use:
pip install -r requirements-dev.txt
Moreover, if you plan to utilize ONNX or TensorRT, please follow :ref:`ONNX`, :ref:`TensorRT` for more installation details.

PyPI (pip install)
------------------

.. note::
Due to the :guilabel:`yolo` this name already being occupied in the PyPI library, we are still determining the package name.
Currently, we provide an alternative way to install via the GitHub repository. Ensure your shell has `git` and `pip3` (or `pip`).

To install YOLO via GitHub:

.. code-block:: bash
pip install git+https://github.com/WongKinYiu/YOLO.git
Docker
------

To run YOLO using NVIDIA Docker, you can pull the Docker image and run it with GPU support:

.. code-block:: bash
docker pull henrytsui000/yolo
docker run --gpus all -it henrytsui000/yolo
Make sure you have the NVIDIA Docker toolkit installed. For more details on setting up NVIDIA Docker, refer to the `NVIDIA Docker documentation <https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html>`_.


Conda
-----

We will publish it in the near future!
3 changes: 0 additions & 3 deletions docs/0_get_start/3_pypi.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/0_get_start/4_docker.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/0_get_start/5_conda.md

This file was deleted.

Loading

0 comments on commit fb4930b

Please sign in to comment.