如何使用大型MS COCO数据集在Tensorflow中训练模型以进行多类对象检测?

时间:2020-05-28 01:50:43

标签: python tensorflow deep-learning artificial-intelligence object-detection-api

我正在尝试使用此https://github.com/tensorflow/models/tree/master/research/object_detection作为参考,在自定义数据集上训练我的模型。 基本上,我的Acer Nitro 50 Desktop具有系统配置 处理器:Intel®Core™i5-8400 CPU @ 2.80GHz×6 图形:GeForce GTX 1050 / PCIe / SSE2(2 GB), 内存(RAM):8GB DDR4内存

我正在使用tensorflow 1.12.0 gpu | bazel 0.15.0 | python 3.5 | GCC 4.8 | cudnn 7 | Cuda 9.0在我的自定义ms coco数据集上训练带有一个10.4 GB(65000张图像)训练数据和533.4 MB(3300张图像)验证数据的我的自定义ms coco数据集上的faster_rcnn_inception_v2_coco模型,以进行200k epochs(num_steps)的对象检测,默认为600 x 1024分辨率(在faster_rcnn_inception_v2_coco中设置)。我正在8个课程上训练和验证模型。因此,当我训练模型时,一段时间后精度(图)不会增加,损耗也不会减少。训练成功完成后,我在各种图像上运行了模型,并注意到了几件事。我有几个问题

  1. 准确性较低
  2. 在某些图像中,所有边界框都没有检测到对象。而在某些多类对象检测中,可以完美地检测到所有对象,但准确度在60-75左右。
  3. 从上面的第二点开始,如果我训练一个具有较少图像和较少类数(3或4)的单独模型,则效果很好,但准确度在75 – 95左右

enter image description here

enter image description here

您可以看到上面的图像,我的模型在总损失和学习率不一致的情况下无法有效训练。因此,地图不会上升,导致精度降低。如果有人可以指导我,那将真的很有帮助。我正试图从一段时间找出这个问题。我没有收到任何错误或警告。

这是在文件fast_rcnn_inception_v2.config中训练模型所需的更改

# Faster R-CNN with Inception v2, configuration for MSCOCO Dataset.
# Users should configure the fine_tune_checkpoint field in the train config as
# well as the label_map_path and input_path fields in the train_input_reader and
# eval_input_reader. Search for "PATH_TO_BE_CONFIGURED" to find the fields that
# should be configured.
model {
  faster_rcnn {
    num_classes: 8
#Default configuration for image_resizer no changes made in this function
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_inception_v2'
      first_stage_features_stride: 16
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [0.25, 0.5, 1.0, 2.0]
        aspect_ratios: [0.5, 1.0, 2.0]
        height_stride: 16
        width_stride: 16
      }
    }
    first_stage_box_predictor_conv_hyperparams {
      op: CONV
      regularizer {
        l2_regularizer {
          weight: 0.0
        }
      }
      initializer {
        truncated_normal_initializer {
          stddev: 0.01
        }
      }
    }
    first_stage_nms_score_threshold: 0.0
    first_stage_nms_iou_threshold: 0.7
    first_stage_max_proposals: 300
    first_stage_localization_loss_weight: 2.0
    first_stage_objectness_loss_weight: 1.0
    initial_crop_size: 14
    maxpool_kernel_size: 2
    maxpool_stride: 2
    second_stage_box_predictor {
      mask_rcnn_box_predictor {
        use_dropout: false
        dropout_keep_probability: 1.0
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
  }
}

train_config: {
  batch_size: 1
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        manual_step_learning_rate {
          initial_learning_rate: 0.0002
          schedule {
            step: 900000
            learning_rate: .00002
          }
          schedule {
            step: 1200000
            learning_rate: .000002
          }
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "models/model.ckpt"
  from_detection_checkpoint: true
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the COCO dataset. This
  # effectively bypasses the learning rate schedule (the learning rate will
  # never decay). Remove the below line to train indefinitely.
  num_steps: 200000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}

train_input_reader: {
  tf_record_input_reader {
    input_path: "data/dataset_tools_train.tfrecord"
  }
  label_map_path: "data/label.pbtxt"
}

eval_config: {
  num_examples: 3300
  # Note: The below line limits the evaluation process to 10 evaluations.
  # Remove the below line to evaluate indefinitely.
  max_evals: 10
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "data/dataset_tools_val.tfrecord"
  }
  label_map_path: "data/dataset_tools_val.tfrecord"
  shuffle: false
  num_readers: 1
} 

0 个答案:

没有答案