Introduction
The APIs of the training component are encapsulated based on the MindSpore source code. The training and evaluation script files of the SSD_MobileNetV1_FPN, ResNet-50, YOLOv4, U-Net, UNet++, CTPN, and CRNN models are provided, covering five application scenarios: object detection, object classification, text detection, text recognition, and semantic segmentation.
The training code is configured by command-line parameters, and is suitable for model training, model conversion, model evaluation, accuracy result saving, and visualization file generation.
Generally, the training code is stored in a folder corresponding to each model. model_train.py and model_eval.py are the entry script files for training and evaluation. Each directory stores the same public function library com_package.
version.info records the training code version. ssd_tiled_dataset_mindspore is created based on the ssd_mobilenet_fpn model for small object detection. scripts stores scripts of tool packages related to training scenarios, such as a data augmentation script. The directory structure of the training code folders is as follows:
.
Training code folders
├── crnn_mindspore
├── ctpn_mindspore
├── resnet50_mindspore
└── scripts
├── com_package # Public function library
└── dataset_tools # Dataset processing tool library
├── coco_data_aug.py # Offline data augmentation for a COCO object detection dataset
├── tag_paste_cls_dataset.py # Obtains images for tag classification.
└── tag_paste_data_augmentation.py # Data augmentation tool for tag classification
├── ssd_mobilenet_fpn_mindspore
├── ssd_tiled_dataset_mindspore
├── unet_mindspore
├── unet_nested_mindspore
├── version.info # Version of the release package
├── wafer_mindspore
└── yolov4_mindspore
├── com_package
├── inside_eval.py
├── inside_train.py
├── model_eval.py # Entry of the evaluation script
├── model_train.py # Entry of the training script
├── model_wrapper # Libraries on which model training and evaluation depend, for example, definitions of the dataset, network, evaluation mode, and callback function
├── om_convert # Converts the OM offline model, including the AIPP configuration file.
├── on_platform # Configuration file provided for the platform
└── pre_trained_ckpt # Stores the pre-trained model.
- Model training: A given training dataset is divided into the training part and the test part. The training part is used to train the model hyperparameters to obtain the CKPT file. Then, the test part is used to evaluate the accuracy and save the CKPT file with the best accuracy and hyperparameter configuration file.
- Model conversion: MindSpore is used to convert the CKPT file with the best accuracy into an AIR file, and then the ATC tool is used to convert the AIR model into an OM model for inference on the Ascend 310 AI Processor and Ascend 310P AI Processor. Model conversion is automatically executed after model training is complete and cannot be executed independently.
- Model evaluation: Based on the given test dataset, the CKPT file with the best accuracy is used to evaluate the model accuracy, and save various visualized tables and evaluation parameter configuration files generated during the evaluation.