使用来自TF对象检测API的新数据集微调对象细分模型的行为是错误的

时间:2018-06-20 13:00:20

标签: python-3.x tensorflow object-detection tensorboard

Python version -> 3.6.4 
TF version -> 1.8.0
Running on : CPU 
OS: Windows 10 

大家好!我正在尝试从TF对象检测API中微调模型以进行对象细分。我使用预先训练的mask_rcnn_inception_v2_coco_2018_01_28作为基准,并且正在LFW Dataset上进行训练,以从头部,头发和面部的图片中进行分割。

我遍历了不同的教程来生成数据集,显然,使用create_pet_tf_record.py脚本将我的数据集成功转换为Train和eval TFrecord文件(我只是修改了加载XML的部分通过直接生成字典以及所有所需部分的函数的图像文件。

train.py脚本没有引发错误,并且训练似乎已经按预期进行,但是当我尝试在1000步之后评估模型(已将其导出到.pb文件之后)时,使用教程中提供的Jupyter笔记本,该模型甚至没有在脸部周围生成盒子。所以我试图观察张量板上的训练,并且发现在所有训练过程中模板损失都保持为零

Capture of the losses

此外(我不知道这是否有帮助),我与其他教程有所不同,我无法从张量板上的评估集中查看图像中的预测。

  

未找到图像数据。

     
    

可能的原因:     您尚未将任何图像数据写入事件文件。     TensorBoard找不到您的事件文件。

  

但是我没有碰到摘要行为。

我的配置文件如下:

    # Mask R-CNN with Inception V2
    # Configured 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: 1
        image_resizer {
          keep_aspect_ratio_resizer {
            min_dimension: 220
            max_dimension: 1365
          }
        }
        number_of_stages: 3
        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]
            aspectratios: [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.0
            }
          }
        }
        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
            predict_instance_masks: true
            mask_height: 15
            mask_width: 15
            mask_prediction_conv_depth: 0
            mask_prediction_num_conv_layers: 2
            fc_hyperparams {
              op: FC
              regularizer {
                l2_regularizer {
                  weight: 0.1
                }
              }
              initializer {
                variance_scaling_initializer {
                  factor: 1.0
                  uniform: true
                  mode: FAN_AVG
                }
              }
            }
            conv_hyperparams {
              op: CONV
              regularizer {
                l2_regularizer {
                  weight: 0.0
                }
              }
              initializer {
                truncated_normal_initializer {
                  stddev: 0.01
                }
              }
            }
          }
        }
        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
        second_stage_mask_prediction_loss_weight: 4.0
      }
    }
    train_config: {
      batch_size: 1
      optimizer {
        momentum_optimizer: {
          learning_rate: {
            manual_step_learning_rate {
              initial_learning_rate: 0.00002
              schedule {
                step: 1000
                learning_rate: .000002
              }
              schedule {
                step: 2000
                learning_rate: .0000002
              }
            }
          }
          momentum_optimizer_value: 0.9
        }
        use_moving_average: false
      }
      gradient_clipping_by_norm: 10.0
      fine_tune_checkpoint: "model/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 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: "data/pictures_with_masks_train.record-00000-of-00001"
      }
      label_map_path: "data/label.pbtxt.txt"
      load_instance_masks: True
      mask_type: PNG_MASKS
    }
    eval_config: {
      num_examples: 878
      # 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/pictures_with_masks_val.record-00000-of-00001"
      }
      label_map_path: "data/label.pbtxt.txt"
      load_instance_masks: True
      mask_type: PNG_MASKS
      shuffle: False
      num_readers: 1
    }

我将非常感谢您提供的任何帮助,如果您有任何想法,请随时回复!

谢谢!

0 个答案:

没有答案