File size: 1,888 Bytes
4a690bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
Train & Validation
==================
Training Model
----------------
To train a model, the :class:`~yolo.tools.solver.ModelTrainer` can help manage the training process. Initialize the :class:`~yolo.tools.solver.ModelTrainer` and use the :func:`~yolo.tools.solver.ModelTrainer.solve` function to start the training.
Before starting the training, don't forget to start the progress logger to enable logging the process status. This will also enable `Weights & Biases (wandb) <https://wandb.ai/site>`_ or TensorBoard if configured.
.. code-block:: python
from yolo import ModelTrainer
solver = ModelTrainer(cfg, model, converter, progress, device, use_ddp)
progress.start()
solver.solve(dataloader)
Training Diagram
~~~~~~~~~~~~~~~~
The following diagram illustrates the training process:
.. mermaid::
flowchart LR
subgraph TS["trainer.solve"]
subgraph TE["train one epoch"]
subgraph "train one batch"
backpropagation-->TF[forward]
TF-->backpropagation
end
end
subgraph validator.solve
VC["calculate mAP"]-->VF[forward]
VF[forward]-->VC
end
end
TE-->validator.solve
validator.solve-->TE
Validation Model
----------------
To validate the model performance, we follow a similar approach as the training process using :class:`~yolo.tools.solver.ModelValidator`.
.. code-block:: python
from yolo import ModelValidator
solver = ModelValidator(cfg, model, converter, progress, device, use_ddp)
progress.start()
solver.solve(dataloader)
The :class:`~yolo.tools.solver.ModelValidator` class helps manage the validation process, ensuring that the model's performance is evaluated accurately.
.. note:: The original training process already includes the validation phase. Call this separately if you want to run the validation again after the training is completed.
|