Image Classification (ResNet-50)
Training Parameters and Value Ranges
Table 1 describes the names, types, value ranges, default values, and descriptions of the ResNet-50 training parameters.
Parameter |
Type |
Value Range |
Default Value |
Description |
|---|---|---|---|---|
--train_dataset_path |
String |
- |
None |
Path of the training dataset. |
--pretrained_ckpt_path |
String |
- |
"pre_trained_ckpt" |
Path for storing the pre-trained model. |
--train_output_path |
String |
- |
"train_output_path" |
Output path of the training result. |
--device_num |
Integer |
Currently, only one device is supported, that is, the value can only be 1. |
1 |
Number of NPUs used for training. |
--device_id |
Integer |
[0,7] |
0 |
ID of the NPU used for training. |
--run_eval |
Bool |
True or False |
True |
Whether to perform evaluation during training. |
--batch_size |
Integer |
|
16 |
Batch size for training. |
--epoch_size |
Integer |
[1,10000] |
10 |
Number of training epochs. |
--init_lr |
Float |
(0,1) |
0.0001 |
Training learning rate. |
--enable_modelarts |
Bool |
True or False |
False |
Whether to use ModelArts for training. |
--data_url |
String |
- |
None |
Dataset path for the ModelArts training. |
--train_output_url |
String |
- |
None |
Output path for the ModelArts training. |
--checkpoint_url |
String |
- |
None |
Path of the pre-trained model for the ModelArts training. |
--net_width |
Integer |
An integer multiple of 16 within [64,608]. |
224 |
Network width. |
--net_height |
Integer |
An integer multiple of 16 within [64,608]. |
224 |
Network height. |
Training Command Reference for ResNet-50
The command for training the ResNet-50 model is as follows:
python3 model_train.py --train_dataset_path={train_dataset_path} --train_output_path=./output_path --epoch_size=10 --batch_size=16 --init_lr=0.0001 --device_num=1 --device_id=0 --run_eval=True
The model training process is random. Use the evaluated accuracy. Figure 1 shows the training accuracy results.
Figure 2 shows the log information after the model training is complete.
After the training is complete, the .ckpt, .a310.om, .a310p.om, and .air model files are generated in the output directory specified by the --train_output_path parameter.
Evaluation Parameters and Value Ranges
Table 2 describes the names, types, value ranges, default values, and descriptions of the ResNet-50 evaluation parameters.
Parameter |
Type |
Value Range |
Default Value |
Description |
|---|---|---|---|---|
--eval_dataset_path |
String |
- |
None |
Path of the evaluation dataset. |
--eval_ckpt_path |
String |
- |
None |
Path for obtaining the evaluation CKPT. |
--eval_output_path |
String |
- |
"eval_output_path" |
Output path of the evaluation results. |
--device_id |
Integer |
[0,7] |
0 |
ID of the NPU for evaluation. |
--enable_modelarts |
Bool |
True or False |
False |
Whether to use ModelArts for training. |
--data_url |
String |
- |
None |
Dataset path for the ModelArts training. |
--eval_output_url |
String |
- |
None |
Output path for the ModelArts training. |
--checkpoint_url |
String |
- |
None |
Path of the pre-trained model for the ModelArts training. |
Evaluation Command Reference
Run the following command to evaluate the ResNet-50 model:
python3 model_eval.py --eval_dataset_path={eval_dataset_path} --eval_ckpt_path=./output_ path --eval_output_path=./eval_result --device_id=0
Use the checkpoint output during the training to evaluate the model accuracy. Figure 3 shows the results.
The folders and file shown in Figure 4 are generated in the evaluation directory. The ng_images folder stores each image that is incorrectly evaluated, the ok_images folder stores each image that is correctly evaluated, and the statistics.csv file stores the evaluation results, including the class name, accuracy rate, recall rate, and accuracy value, as well as the number of tags, detected images and correctly detected images.



