Tensorflow GPU自定义对象检测不工作

Tensorflow GPU自定义对象检测不工作,tensorflow,object-detection,custom-object,Tensorflow,Object Detection,Custom Object,我对使用tensorflow进行目标检测比较陌生,需要以下问题的指导 我正在构建一个自定义模型,使用tensorflow和Faster_Rcnn_inception_v2模型检测两个对象。为此,我使用了600个包含这两个对象的图像。这些图像分为75%的train和25%的test文件夹。 我能够在GPU(Linux)机器上使用该模型进行训练,并且只实现了0.05的损失 在生成冻结的_推断_graph.pb文件后,当我测试时,它甚至在10多幅图像中检测不到单个对象。 只有当我将min_score_

我对使用tensorflow进行目标检测比较陌生,需要以下问题的指导

我正在构建一个自定义模型,使用tensorflow和Faster_Rcnn_inception_v2模型检测两个对象。为此,我使用了600个包含这两个对象的图像。这些图像分为75%的train和25%的test文件夹。 我能够在GPU(Linux)机器上使用该模型进行训练,并且只实现了0.05的损失 在生成冻结的_推断_graph.pb文件后,当我测试时,它甚至在10多幅图像中检测不到单个对象。 只有当我将min_score_thresh参数的值降低到0.4时,它才起作用 检测对象的置信度约为47%

然而,当我在不同的CPU(Windows)机器上训练相同的模型时,它工作得非常好,结果令人满意,置信度在80%以上

有人能解释一下这个问题吗?为什么在GPU上训练时模型不工作,而在CPU上训练时模型工作

注意:该问题仅发生在最近,2个月前,GPU模型针对不同的对象异常工作

如果需要,我可以共享config labelmap或任何其他文件的内容

训练指挥部:

python train.py --logtostderr --train_dir="TrainingDp" --pipeline_config_path="TrainingDp/faster_rcnn.config"
代码:

配置文件的内容:

    # Faster R-CNN with Inception v2, configured for Oxford-IIIT Pets 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: 2
    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: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the pets 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: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/Train.record"
  }
  label_map_path: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/TrainingDp2/labelmap.pbtxt"
}

eval_config: {
  metrics_set: "coco_detection_metrics"
  num_examples: 1101
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/Test.record"
  }
  label_map_path: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/TrainingDp2/labelmap.pbtxt"
  shuffle: false
  num_readers: 1
}

谢谢。

如果有人有同样的问题,
我通过更改配置文件中的batch_size=2来解决问题。

如果有人有相同的问题,
我通过更改配置文件中的batch_size=2解决了此问题。

请将您正在处理的代码添加到问题中Hi Aragon,我已经添加了代码。请将您正在处理的代码添加到问题中Hi Aragon,我已经添加了代码。
    # Faster R-CNN with Inception v2, configured for Oxford-IIIT Pets 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: 2
    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: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/faster_rcnn_inception_v2_coco_2018_01_28/model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  # Note: The below line limits the training process to 200K steps, which we
  # empirically found to be sufficient enough to train the pets 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: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/Train.record"
  }
  label_map_path: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/TrainingDp2/labelmap.pbtxt"
}

eval_config: {
  metrics_set: "coco_detection_metrics"
  num_examples: 1101
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/Test.record"
  }
  label_map_path: "C:/Users/xxxxxx/Desktop/models-master/models-master/research/object_detection/TrainingDp2/labelmap.pbtxt"
  shuffle: false
  num_readers: 1
}