Inspection
mindrecord
The following table describes the names, types, value ranges, default values, and descriptions of evaluation parameters of the mindrecord model.
Parameter |
Type |
Value Range |
Default Value |
Description |
|---|---|---|---|---|
--config |
String |
- |
None |
(Optional) Parameter configuration file path, whose permission must be set to 400. |
--ratio |
Float |
(0 ,1) |
0.8 |
Proportion of the training dataset. |
--input_chip_id |
String |
- |
None |
Processor ID. |
--input_setup_id |
String |
- |
"" |
Processor layer. |
--minddata_train |
String |
- |
"" |
Path that stores the MindRecord training dataset. |
--minddata_val |
String |
- |
"" |
Path that stores the MindRecord validation dataset. |
--rgb_dir |
String |
- |
rgb_ref/ |
Path that stores the RGB reference images. |
--gray_dir |
String |
- |
gray_ref/ |
Path for saving the grayscale images. |
--mask_dir |
String |
- |
mask_ref/ |
Path that stores mask images. |
--train_flag |
Bool |
True or False |
True |
Whether to balance training dataset. |
--data_txt |
String |
- |
None |
Registered .txt file. |
--num_threads |
Integer |
[1,8] |
2 |
Number of used processes. |
Images in rgb_dir, gray_dir, and mask_dir must be named in the specified format. The following is an example:
When input_chip_id is set to 001 and input_setup_id is set to M1, the reference image in rgb_dir must be named 001_M1_rgb_golden_die.png, the grayscale image in gray_dir must be named 001_M1_gray_golden_die.png, and the mask image must be named 001_M1_viaconductor_mask.png.
data_txt must be a TXT file, which describes information about images photographed at a machine and must comply with the following rules:
- Each line corresponds to an image.
- Each line contains 12 fields.
- Fields are separated by a space.
For details about the fields, see Table 2. The following is a compilation example.
Create a data.txt file, which contains the following three lines of character strings:
img_1.jpg 001 M1 11224.435 12925.229 0 wafer_id1 01-08-22-13:09:22; device_id1 L21510106 model1 20 img_2.jpg 001 M1 13817.899 17822.569 0 wafer_id2 12-29-21-08:17:05; device_id1 L21510104 model2 20 img_3.jpg 001 M1 970.857 24809.092 0 wafer_id3 12-21-21-06:02:08; device_id3 L21510206 model3 20
Index |
Type |
Value Range |
Description |
|---|---|---|---|
0 |
String |
- |
Image path |
1 |
String |
- |
Processor ID. |
2 |
String |
- |
Processor layer. |
3 |
Float |
[0, 100000] |
X coordinate of an image |
4 |
Float |
[0, 100000] |
Y coordinate of an image |
5 |
Integer |
0 or 2 |
Image label |
6 |
String |
- |
Wafer ID |
7 |
String |
- |
Timestamp |
8 |
String |
- |
Device ID |
9 |
String |
- |
Batch number |
10 |
String |
- |
Device model |
11 |
Integer |
[1, 1000] |
Magnification ratio |
The command for generating the mindrecord files is as follows:
python3 generate_mindrecords.py --config <config_path>
<config_path>: parameter list required for generating the mindrecord files.

Before training the inspection model, you need to convert the dataset into mindrecord files. Images cannot be directly used as the training dataset. Instead, you need to use the generated mindrecord files for training.

Training Parameters and Value Ranges
Table 3 describes the names, types, value ranges, default values, and descriptions of training parameters of the inspection model.
Parameter |
Type |
Value Range |
Default Value |
Description |
|---|---|---|---|---|
--config |
String |
- |
None |
(Optional) Parameter configuration file path, whose permission must be set to 400. |
--training_data |
String |
- |
./xxx/yyy/zzz" |
Path of the MindRecord training dataset. If there are multiple datasets, separate them separated with commas (,). |
--validation_data |
String |
- |
./xxx/yyy/zzz" |
Path of the MindRecord validation datasets. If there are multiple datasets, separate them separated with commas (,). |
--save_checkpoint_dir |
String |
- |
'./ckpt' |
Path for saving the checkpoint. |
--save_fnfp |
String |
"yes", "no" |
no |
Whether to save images that are incorrectly predicted. |
--fnfp_path |
String |
- |
./saved_fnfp_images |
Path for saving fn and fp images. |
--recall |
Float |
(0 ,1) |
0.99 |
Recall rate. |
--device_target |
String |
"Ascend" or "GPU" |
"Ascend" |
Training platform. |
--steps_per_eval |
Integer |
[1,10000] |
1000 |
Number of evaluation intervals. |
--epochs |
Integer |
[1,10000] |
300 |
Number of training epochs. |
--batch_size |
Integer |
[1, 128] |
16 |
Batch size for training. |
--ref_type |
String |
"rgb", "gray" |
'rgb' |
Type of reference images. |
--ref_dir |
String |
- |
'./xxx/yyy/zzz' |
Path that stores the reference images. |
--bytes_dataset |
String |
"yes", "no" |
'yes' |
Whether to stitch reference images. |
--chip_setups |
String |
- |
"" |
Processor ID and layer. If there are multiple IDs and layers, separate them with commas (,). |
--auto_balance |
String |
"filter", "sampler", "yes", "no" |
'filter' |
Data balancing mode. |
--use_val_filter |
Integer |
[0, 10000] |
2000 |
Maximum number of passes used by the validation dataset. |
--input_res |
Integer |
[256, 1024] |
256 |
Image resolution. |
Create two subdirectories rgb_ref and gray_ref in ref_dir. The files in the subdirectories must be named in the specified format. The following is an example:
When chip_setups is set to 001M1, the reference image in rgb_ref must be named 001_M1_rgb_golden_die.png, and the grayscale image in gray_ref must be named 001_M1_gray_golden_die.png.
Training Command Reference
The command for training the inspection model is as follows:
python3 inspection_train.py --config <config_path>
<config_path> indicates the list of parameters required for inspecting model training.
The model training process is random. Use the evaluated accuracy. The training accuracy is displayed as follows:

After the training is complete, a .ckpt model file is generated in the output directory specified by the --save_checkpoint_dir parameter. Generate an AIR model by referring to the following code, and then use the model conversion tool to convert the AIR model into an OM model for inference.
