models icon indicating copy to clipboard operation
models copied to clipboard

The RFCN module's [email protected] is quite low

Open auroua opened this issue 9 years ago • 8 comments

I have trained rfcn module on voc 2007+2012 trainval datasets, and tested on voc 2007 test. The [email protected] is quite low. I used a pretrained resnet module to initialize the backbone feature extractor. The config file as follows:

# R-FCN with Resnet-101 (v1),  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: 90
    num_classes: 20
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 600
        max_dimension: 1024
      }
    }
    feature_extractor {
      type: 'faster_rcnn_resnet101'
      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.0005
        }
      }
      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
    second_stage_box_predictor {
      rfcn_box_predictor {
        conv_hyperparams {
          op: CONV
          regularizer {
            l2_regularizer {
              weight: 0.0005
            }
          }
          initializer {
            truncated_normal_initializer {
              stddev: 0.01
            }
          }
        }
        crop_height: 18
        crop_width: 18
        num_spatial_bins_height: 3
        num_spatial_bins_width: 3
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.7
        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
#    hard_example_miner {
#      num_hard_examples: 128
#      iou_threshold: 0.7
#    }
  }
}

train_config: {
  batch_size: 1
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        manual_step_learning_rate {
          initial_learning_rate: 0.0003
          schedule {
            step: 0
            learning_rate: .0003
          }
          schedule {
            step: 900000
            learning_rate: .00003
          }
          schedule {
            step: 1200000
            learning_rate: .000003
          }
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  gradient_clipping_by_norm: 10.0
  fine_tune_checkpoint: "/home/aurora/pretrained_models/tensorflow_backbone_network/resnet_v1_101/resnet_v1_101.ckpt"
  from_detection_checkpoint: false
  # 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: 1500000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
}

train_input_reader: {
  tf_record_input_reader {
    input_path: "/home/aurora/workspaces/data/tfrecords_data/voc_dataset/trainval.tfrecords"
  }
  label_map_path: "/home/aurora/workspaces/PycharmProjects/tensorflow/tensorflow_object_detection/object_detection/data/pascal_label_map.pbtxt"
}

eval_config: {
#  num_examples: 8000
  num_examples: 4952
  num_visualizations: 4952
  # Note: The below line limits the evaluation process to 10 evaluations.
  # Remove the below line to evaluate indefinitely.
  max_evals: 1
  visualization_export_dir: '/home/aurora/workspaces/PycharmProjects/tensorflow/tensorflow_object_detection/outputs_eval_imgs'
  metrics_set: 'pascal_voc_metrics'
}

eval_input_reader: {
  tf_record_input_reader {
    input_path: "/home/aurora/workspaces/data/tfrecords_data/voc_dataset/test.tfrecords"
  }
  label_map_path: "/home/aurora/workspaces/PycharmProjects/tensorflow/tensorflow_object_detection/object_detection/data/pascal_label_map.pbtxt"
  shuffle: false
  num_readers: 1
  num_epochs: 1
}

The results as follows:

INFO:root:PerformanceByCategory/[email protected]/aeroplane: 0.746511
INFO:root:PerformanceByCategory/[email protected]/bicycle: 0.726148
INFO:root:PerformanceByCategory/[email protected]/bird: 0.644425
INFO:root:PerformanceByCategory/[email protected]/boat: 0.503916
INFO:root:PerformanceByCategory/[email protected]/bottle: 0.464546
INFO:root:PerformanceByCategory/[email protected]/bus: 0.712661
INFO:root:PerformanceByCategory/[email protected]/car: 0.753141
INFO:root:PerformanceByCategory/[email protected]/cat: 0.829336
INFO:root:PerformanceByCategory/[email protected]/chair: 0.450476
INFO:root:PerformanceByCategory/[email protected]/cow: 0.749528
INFO:root:PerformanceByCategory/[email protected]/diningtable: 0.524046
INFO:root:PerformanceByCategory/[email protected]/dog: 0.813294
INFO:root:PerformanceByCategory/[email protected]/horse: 0.794916
INFO:root:PerformanceByCategory/[email protected]/motorbike: 0.728557
INFO:root:PerformanceByCategory/[email protected]/person: 0.747905
INFO:root:PerformanceByCategory/[email protected]/pottedplant: 0.368039
INFO:root:PerformanceByCategory/[email protected]/sheep: 0.663642
INFO:root:PerformanceByCategory/[email protected]/sofa: 0.624955
INFO:root:PerformanceByCategory/[email protected]/train: 0.788748
INFO:root:PerformanceByCategory/[email protected]/tvmonitor: 0.651828
INFO:root:Precision/[email protected]: 0.664331

How can I improve the performance?

auroua avatar Oct 23 '17 00:10 auroua

This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks!

skye avatar Oct 27 '17 18:10 skye

https://stackoverflow.com/questions/50998416/tensorflow-object-detection-the-rfcn-modules-map0-5-is-quite-low

Is this problem solved?

chengmengli06 avatar Jun 23 '18 06:06 chengmengli06

I meet the same issue with model_main.py. Do you solve the problem?

zhangmengya avatar Nov 16 '18 08:11 zhangmengya

After fix quite a few bugs, I finally reach the same accuracy as caffe version. But I cannot release the code now. We release an inner maintained tensorflow soon, and the fixes will be released along with it. @zhangmengya

chengmengli06 avatar Nov 16 '18 08:11 chengmengli06

@chengmengli06 thanks. Could you tell me the approximate time when you release? If possible, you could tell me where the bugs exist. Thanks again.

zhangmengya avatar Nov 16 '18 08:11 zhangmengya

@chengmengli06 I read your pull request and I'm not really sure about the reason why you did these changes. I have worked on model_main.py for a long time and it seems not supporting multiple workers training right now. Can you share something with us about the bugs you found in RFCN? Really appreciate that!

TonyGongjc avatar Nov 23 '18 02:11 TonyGongjc

Hi @TonyGongjc @chengmengli06 Where can I find the pull request?

kindloaf avatar Feb 08 '19 21:02 kindloaf

@chengmengli06 Is the following commit related? https://github.com/chengmengli06/tensorflow/commit/e81d0c5499eab1ae2d301c5caa128e0b69b0289b

When you fixed some bugs, do you refer to the bugs in the object detection API, or the Tensorflow library code?

kindloaf avatar Feb 08 '19 21:02 kindloaf