YOLO NAS trains its own data set

Environmental preparation

yolo nas source code: https://github.com/Deci-AI/super-gradients.git
refer to the readme file: just one line of instructions for environment configuration

pip install super-gradients

Dataset preparation

Yolo nas target detection supports data sets in three formats: coco, voc, and yolo. The data set in yolo format is used here.
The super-gradients/src/super_gradients/training/datasets/detection_datasetsfollowing files have instructions:
Insert image description here
Insert image description here

file modification

I am a grape data set, so the file is named after grape.

To pass in your own data set, you need to modify the following files:

1. under the recipes main directory

Directory: super-gradients/src/super_gradients/recipes/grape_yolo_nas_s.yaml
Copy coco_yolo_nas_s.yaml, modify it to your own configuration file, and rename other files in the same way:

defaults:
  - training_hyperparams: coco2017_yolo_nas_train_params 
  - # 文件目录src/super_gradients/recipes/training_hyperparams/coco2017_yolo_nas_train_params.yaml
  - # 需要修改epochs在此文件中修改
  - dataset_params: grape_detection_yolo_format_base_dataset_params
  - # 文件目录src/super_gradients/recipes/dataset_params/grape_detection_yolo_format_base_dataset_params.yaml
  - # 此处修改见说明-dataset_params修改
  - arch_params: yolo_nas_s_arch_params
  - checkpoint_params: default_checkpoint_params
  - _self_
  - variable_setup

train_dataloader: grape_detection_yolo_format_train
val_dataloader: grape_detection_yolo_format_val

load_checkpoint: False
resume: False

dataset_params:
  train_dataloader_params:
    batch_size: 4

arch_params:
  num_classes: 1

training_hyperparams:
  resume: ${
    
    resume}
  mixed_precision: True

architecture: yolo_nas_s

multi_gpu: DDP
num_gpus: 1

experiment_suffix: ""
experiment_name: coco2017_${
    
    architecture}${
    
    experiment_suffix}

-dataset_params modification:

Directory/src/super_gradients/recipes/dataset_params/grape_detection_yolo_format_base_dataset_params.yaml
1. Modify the training data set directory
Insert image description here

2. Verify the modification of the data set directory
Insert image description here

2.dataloaders.py file modification

File directory: src/super_gradients/training/dataloaders/dataloaders.py
Copy the coco_detection_yolo_format_train function and modify:
Insert image description here
Copy the coco_detection_yolo_format_val function and modify:
Insert image description here
Note: The file corresponding to the config_name name here is the file modified by dataset_params in step 1, except for the suffix

3.Object_names.py file modification

File directory: src/super_gradients/common/object_names.py
Insert image description here

start training

python src/super_gradients/examples/train_from_recipe_example/train_from_recipe.py --config-name=grape_yolo_nas_s.yaml

Insert image description here

Guess you like

Origin blog.csdn.net/balabala_333/article/details/132183996