我正在使用 PixelLib 来创建自定义培训。这些是我的训练步骤:
train_maskrcnn = instance_custom_training()
train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes= 2, batch_size = 4)
train_maskrcnn.load_pretrained_model("mask_rcnn_coco.h5")
train_maskrcnn.load_dataset("Custom")
train_maskrcnn.train_model(num_epochs = 20, augmentation=True, path_trained_models = "mask_rcnn_models")
我得到的结果是:
Using resnet101 as network backbone For Mask R-CNN model
Applying Default Augmentation on Dataset
Train 22 images
Validate 8 images
Checkpoint Path: /content/mask_rcnn_models
Selecting layers to train
Epoch 1/20
100/100 [==============================] - 241s 2s/step - batch: 49.5000 - size: 4.0000 - loss: 2.0358 - rpn_class_loss: 0.0581 - rpn_bbox_loss: 1.1891 - mrcnn_class_loss: 0.0982 - mrcnn_bbox_loss: 0.3467 - mrcnn_mask_loss: 0.3437 - val_loss: 2.0740 - val_rpn_class_loss: 0.0223 - val_rpn_bbox_loss: 0.3395 - val_mrcnn_class_loss: 0.3975 - val_mrcnn_bbox_loss: 0.5588 - val_mrcnn_mask_loss: 0.7558
Epoch 2/20
100/100 [==============================] - 147s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 1.4382 - rpn_class_loss: 0.0442 - rpn_bbox_loss: 1.0192 - mrcnn_class_loss: 0.0267 - mrcnn_bbox_loss: 0.1487 - mrcnn_mask_loss: 0.1995 - val_loss: 1.4399 - val_rpn_class_loss: 0.0139 - val_rpn_bbox_loss: 0.2485 - val_mrcnn_class_loss: 0.3519 - val_mrcnn_bbox_loss: 0.4401 - val_mrcnn_mask_loss: 0.3855
Epoch 3/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.9786 - rpn_class_loss: 0.0305 - rpn_bbox_loss: 0.6334 - mrcnn_class_loss: 0.0177 - mrcnn_bbox_loss: 0.1141 - mrcnn_mask_loss: 0.1828 - val_loss: 1.4530 - val_rpn_class_loss: 0.0161 - val_rpn_bbox_loss: 0.3851 - val_mrcnn_class_loss: 0.3750 - val_mrcnn_bbox_loss: 0.3869 - val_mrcnn_mask_loss: 0.2899
Epoch 4/20
100/100 [==============================] - 146s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.7559 - rpn_class_loss: 0.0187 - rpn_bbox_loss: 0.4889 - mrcnn_class_loss: 0.0153 - mrcnn_bbox_loss: 0.0659 - mrcnn_mask_loss: 0.1671 - val_loss: 1.4079 - val_rpn_class_loss: 0.0100 - val_rpn_bbox_loss: 0.2967 - val_mrcnn_class_loss: 0.3926 - val_mrcnn_bbox_loss: 0.4213 - val_mrcnn_mask_loss: 0.2873
Epoch 5/20
100/100 [==============================] - 146s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 1.0271 - rpn_class_loss: 0.0166 - rpn_bbox_loss: 0.7779 - mrcnn_class_loss: 0.0099 - mrcnn_bbox_loss: 0.0565 - mrcnn_mask_loss: 0.1662 - val_loss: 1.4076 - val_rpn_class_loss: 0.0100 - val_rpn_bbox_loss: 0.3964 - val_mrcnn_class_loss: 0.3735 - val_mrcnn_bbox_loss: 0.3409 - val_mrcnn_mask_loss: 0.2869
Epoch 6/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.7035 - rpn_class_loss: 0.0092 - rpn_bbox_loss: 0.4923 - mrcnn_class_loss: 0.0097 - mrcnn_bbox_loss: 0.0392 - mrcnn_mask_loss: 0.1532 - val_loss: 1.8609 - val_rpn_class_loss: 0.0236 - val_rpn_bbox_loss: 0.8049 - val_mrcnn_class_loss: 0.3689 - val_mrcnn_bbox_loss: 0.3855 - val_mrcnn_mask_loss: 0.2780
Epoch 7/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.5849 - rpn_class_loss: 0.0075 - rpn_bbox_loss: 0.3921 - mrcnn_class_loss: 0.0098 - mrcnn_bbox_loss: 0.0303 - mrcnn_mask_loss: 0.1452 - val_loss: 1.6860 - val_rpn_class_loss: 0.0112 - val_rpn_bbox_loss: 0.5972 - val_mrcnn_class_loss: 0.4159 - val_mrcnn_bbox_loss: 0.3982 - val_mrcnn_mask_loss: 0.2635
Epoch 8/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.3516 - rpn_class_loss: 0.0041 - rpn_bbox_loss: 0.1859 - mrcnn_class_loss: 0.0075 - mrcnn_bbox_loss: 0.0190 - mrcnn_mask_loss: 0.1351 - val_loss: 1.6668 - val_rpn_class_loss: 0.0185 - val_rpn_bbox_loss: 0.6575 - val_mrcnn_class_loss: 0.3610 - val_mrcnn_bbox_loss: 0.3404 - val_mrcnn_mask_loss: 0.2893
Epoch 9/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.3997 - rpn_class_loss: 0.0036 - rpn_bbox_loss: 0.2340 - mrcnn_class_loss: 0.0072 - mrcnn_bbox_loss: 0.0207 - mrcnn_mask_loss: 0.1342 - val_loss: 2.2879 - val_rpn_class_loss: 0.0249 - val_rpn_bbox_loss: 1.3610 - val_mrcnn_class_loss: 0.2823 - val_mrcnn_bbox_loss: 0.3445 - val_mrcnn_mask_loss: 0.2752
Epoch 10/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.4649 - rpn_class_loss: 0.0053 - rpn_bbox_loss: 0.3095 - mrcnn_class_loss: 0.0067 - mrcnn_bbox_loss: 0.0192 - mrcnn_mask_loss: 0.1242 - val_loss: 1.5162 - val_rpn_class_loss: 0.0103 - val_rpn_bbox_loss: 0.4022 - val_mrcnn_class_loss: 0.4144 - val_mrcnn_bbox_loss: 0.4181 - val_mrcnn_mask_loss: 0.2712
Epoch 11/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.4638 - rpn_class_loss: 0.0046 - rpn_bbox_loss: 0.2986 - mrcnn_class_loss: 0.0068 - mrcnn_bbox_loss: 0.0223 - mrcnn_mask_loss: 0.1315 - val_loss: 2.3050 - val_rpn_class_loss: 0.0228 - val_rpn_bbox_loss: 1.3584 - val_mrcnn_class_loss: 0.3212 - val_mrcnn_bbox_loss: 0.3367 - val_mrcnn_mask_loss: 0.2659
Epoch 12/20
100/100 [==============================] - 146s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.3238 - rpn_class_loss: 0.0031 - rpn_bbox_loss: 0.1749 - mrcnn_class_loss: 0.0052 - mrcnn_bbox_loss: 0.0169 - mrcnn_mask_loss: 0.1237 - val_loss: 2.4684 - val_rpn_class_loss: 0.0400 - val_rpn_bbox_loss: 1.5882 - val_mrcnn_class_loss: 0.2484 - val_mrcnn_bbox_loss: 0.3032 - val_mrcnn_mask_loss: 0.2885
Epoch 13/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.5377 - rpn_class_loss: 0.0047 - rpn_bbox_loss: 0.3737 - mrcnn_class_loss: 0.0061 - mrcnn_bbox_loss: 0.0214 - mrcnn_mask_loss: 0.1318 - val_loss: 2.0484 - val_rpn_class_loss: 0.0232 - val_rpn_bbox_loss: 1.0450 - val_mrcnn_class_loss: 0.3597 - val_mrcnn_bbox_loss: 0.3366 - val_mrcnn_mask_loss: 0.2839
Epoch 14/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.2957 - rpn_class_loss: 0.0028 - rpn_bbox_loss: 0.1578 - mrcnn_class_loss: 0.0047 - mrcnn_bbox_loss: 0.0128 - mrcnn_mask_loss: 0.1175 - val_loss: 1.9857 - val_rpn_class_loss: 0.0185 - val_rpn_bbox_loss: 0.9357 - val_mrcnn_class_loss: 0.4236 - val_mrcnn_bbox_loss: 0.3229 - val_mrcnn_mask_loss: 0.2851
Epoch 15/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.3760 - rpn_class_loss: 0.0030 - rpn_bbox_loss: 0.2370 - mrcnn_class_loss: 0.0053 - mrcnn_bbox_loss: 0.0134 - mrcnn_mask_loss: 0.1173 - val_loss: 2.3490 - val_rpn_class_loss: 0.0334 - val_rpn_bbox_loss: 1.2769 - val_mrcnn_class_loss: 0.3837 - val_mrcnn_bbox_loss: 0.3328 - val_mrcnn_mask_loss: 0.3223
Epoch 16/20
100/100 [==============================] - 144s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.3394 - rpn_class_loss: 0.0029 - rpn_bbox_loss: 0.2055 - mrcnn_class_loss: 0.0052 - mrcnn_bbox_loss: 0.0125 - mrcnn_mask_loss: 0.1133 - val_loss: 1.9037 - val_rpn_class_loss: 0.0230 - val_rpn_bbox_loss: 1.0319 - val_mrcnn_class_loss: 0.2789 - val_mrcnn_bbox_loss: 0.2761 - val_mrcnn_mask_loss: 0.2938
Epoch 17/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.3121 - rpn_class_loss: 0.0025 - rpn_bbox_loss: 0.1735 - mrcnn_class_loss: 0.0047 - mrcnn_bbox_loss: 0.0142 - mrcnn_mask_loss: 0.1172 - val_loss: 2.1224 - val_rpn_class_loss: 0.0291 - val_rpn_bbox_loss: 1.1942 - val_mrcnn_class_loss: 0.2705 - val_mrcnn_bbox_loss: 0.3293 - val_mrcnn_mask_loss: 0.2991
Epoch 18/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.2742 - rpn_class_loss: 0.0028 - rpn_bbox_loss: 0.1484 - mrcnn_class_loss: 0.0044 - mrcnn_bbox_loss: 0.0102 - mrcnn_mask_loss: 0.1085 - val_loss: 2.1801 - val_rpn_class_loss: 0.0321 - val_rpn_bbox_loss: 1.2540 - val_mrcnn_class_loss: 0.2767 - val_mrcnn_bbox_loss: 0.2970 - val_mrcnn_mask_loss: 0.3204
Epoch 19/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.2662 - rpn_class_loss: 0.0025 - rpn_bbox_loss: 0.1441 - mrcnn_class_loss: 0.0053 - mrcnn_bbox_loss: 0.0097 - mrcnn_mask_loss: 0.1045 - val_loss: 2.3560 - val_rpn_class_loss: 0.0363 - val_rpn_bbox_loss: 1.4240 - val_mrcnn_class_loss: 0.3074 - val_mrcnn_bbox_loss: 0.2889 - val_mrcnn_mask_loss: 0.2993
Epoch 20/20
100/100 [==============================] - 145s 1s/step - batch: 49.5000 - size: 4.0000 - loss: 0.2240 - rpn_class_loss: 0.0024 - rpn_bbox_loss: 0.1018 - mrcnn_class_loss: 0.0049 - mrcnn_bbox_loss: 0.0110 - mrcnn_mask_loss: 0.1039 - val_loss: 2.2898 - val_rpn_class_loss: 0.0403 - val_rpn_bbox_loss: 1.3747 - val_mrcnn_class_loss: 0.2761 - val_mrcnn_bbox_loss: 0.3039 - val_mrcnn_mask_loss: 0.29
因此,损失是一个可接受的值(大约 0.22),但是当我评估模型时:
train_maskrcnn = instance_custom_training()
train_maskrcnn.modelConfig(network_backbone = "resnet101", num_classes= 2)
train_maskrcnn.load_dataset("Custom")
train_maskrcnn.evaluate_model("/content/mask_rcnn_models")
我得到了这个结果:
Using resnet101 as network backbone For Mask R-CNN model
/content/mask_rcnn_models/mask_rcnn_model.001-2.073964.h5 evaluation using iou_threshold 0.5 is 0.000000
/content/mask_rcnn_models/mask_rcnn_model.002-1.439887.h5 evaluation using iou_threshold 0.5 is 0.000000
/content/mask_rcnn_models/mask_rcnn_model.004-1.407873.h5 evaluation using iou_threshold 0.5 is 0.000000
/content/mask_rcnn_models/mask_rcnn_model.005-1.407646.h5 evaluation using iou_threshold 0.5 is 0.000000
这看起来很奇怪,因为损失很低但 IoU 值正好是 0.0。可能是什么问题,我该如何解决?提前致谢