Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么使用tensorflow进行目标检测时,平均精确度和平均召回率很低?_Python_Tensorflow_Object Detection - Fatal编程技术网

Python 为什么使用tensorflow进行目标检测时,平均精确度和平均召回率很低?

Python 为什么使用tensorflow进行目标检测时,平均精确度和平均召回率很低?,python,tensorflow,object-detection,Python,Tensorflow,Object Detection,我用它来学习windows 10上的对象检测 我使用anaconda(python3.6),tensorflow 1.12.0 我准备了400张图片,并将它们分为两类(石头和汽车) 然后我用这个命令来训练: cd E:\test\models master\research\object\u detection python模型_main.py --管道配置路径=训练/ssd\u mobilenet\u v1\u coco.config--model\u dir=training/--num\u

我用它来学习windows 10上的对象检测

我使用anaconda(python3.6),tensorflow 1.12.0

我准备了400张图片,并将它们分为两类(石头和汽车)

然后我用这个命令来训练:

cd E:\test\models master\research\object\u detection

python模型_main.py --管道配置路径=训练/ssd\u mobilenet\u v1\u coco.config--model\u dir=training/--num\u train\u steps=10000

ssd_mobilenet_v1_coco.config中的内容:

# SSD with Mobilenet 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 {
  ssd {
    num_classes: 2
    box_coder {
      faster_rcnn_box_coder {
        y_scale: 10.0
        x_scale: 10.0
        height_scale: 5.0
        width_scale: 5.0
      }
    }
    matcher {
      argmax_matcher {
        matched_threshold: 0.5
        unmatched_threshold: 0.5
        ignore_thresholds: false
        negatives_lower_than_unmatched: true
        force_match_for_each_row: true
      }
    }
    similarity_calculator {
      iou_similarity {
      }
    }
    anchor_generator {
      ssd_anchor_generator {
        num_layers: 6
        min_scale: 0.2
        max_scale: 0.95
        aspect_ratios: 1.0
        aspect_ratios: 2.0
        aspect_ratios: 0.5
        aspect_ratios: 3.0
        aspect_ratios: 0.3333
      }
    }
    image_resizer {
      fixed_shape_resizer {
        height: 300
        width: 300
      }
    }
    box_predictor {
      convolutional_box_predictor {
        min_depth: 0
        max_depth: 0
        num_layers_before_predictor: 0
        use_dropout: false
        dropout_keep_probability: 0.8
        kernel_size: 1
        box_code_size: 4
        apply_sigmoid_to_scores: false
        conv_hyperparams {
          activation: RELU_6,
          regularizer {
            l2_regularizer {
              weight: 0.00004
            }
          }
          initializer {
            truncated_normal_initializer {
              stddev: 0.03
              mean: 0.0
            }
          }
          batch_norm {
            train: true,
            scale: true,
            center: true,
            decay: 0.9997,
            epsilon: 0.001,
          }
        }
      }
    }
    feature_extractor {
      type: 'ssd_mobilenet_v1'
      min_depth: 16
      depth_multiplier: 1.0
      conv_hyperparams {
        activation: RELU_6,
        regularizer {
          l2_regularizer {
            weight: 0.00004
          }
        }
        initializer {
          truncated_normal_initializer {
            stddev: 0.03
            mean: 0.0
          }
        }
        batch_norm {
          train: true,
          scale: true,
          center: true,
          decay: 0.9997,
          epsilon: 0.001,
        }
      }
    }
    loss {
      classification_loss {
        weighted_sigmoid {
        }
      }
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      hard_example_miner {
        num_hard_examples: 3000
        iou_threshold: 0.99
        loss_type: CLASSIFICATION
        max_negatives_per_positive: 3
        min_negatives_per_image: 0
      }
      classification_weight: 1.0
      localization_weight: 1.0
    }
    normalize_loss_by_num_matches: true
    post_processing {
      batch_non_max_suppression {
        score_threshold: 1e-8
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 100
      }
      score_converter: SIGMOID
    }
  }
}

train_config: {
  batch_size: 10
  optimizer {
    rms_prop_optimizer: {
      learning_rate: {
        exponential_decay_learning_rate {
          initial_learning_rate: 0.004
          decay_steps: 800720
          decay_factor: 0.95
        }
      }
      momentum_optimizer_value: 0.9
      decay: 0.9
      epsilon: 1.0
    }
  }
  #fine_tune_checkpoint: "PATH_TO_BE_CONFIGURED/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: 1000
  data_augmentation_options {
    random_horizontal_flip {
    }
  }
  data_augmentation_options {
    ssd_random_crop {
    }
  }
}

train_input_reader: {
  tf_record_input_reader {
    input_path:'data/train.record'
  }
  label_map_path:'data/side_vehicle.pbtxt'
}

eval_config: {
  num_examples: 8000
  # 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/test.record'
  }
  label_map_path: 'data/side_vehicle.pbtxt'
  shuffle: false
  num_readers: 1
}
现在它已经训练了6000个步骤,但是平均精度和平均召回率都不接近1,可以从下面的图片中看到:

pycharm的终端输出此信息:


如何提高平均准确率和平均召回率?我知道问题出在哪里

首先,图片太少,我把图片数量增加到4000张

其次,我应该使用微调。我在管道配置文件中添加了4个部分
ssd\u mobilenet\u v1\u coco.config

  fine_tune_checkpoint: "ssd_inception_v2_coco_2018_01_28/model.ckpt"
  fine_tune_checkpoint_type: "detection"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
再次检查标签,查看是否有任何错误标签的图片。检查是非常重要的

平均查准率和平均查全率随之提高


如果地图达到1,则不是最好的。如果它达到0.48左右,则功能非常强大。

只是一个猜测,如果不查看您的数据,很难判断:数据量和数值步数可能不足以让模型了解实际差异。如果是这种情况,并且这是您的第一个ML项目之一,请首先尝试使用已知的数据集,在那里您可以期望高精度。您是否可以尝试使用项目所有者提供的任何其他配置文件,如同一配置文件的下一个版本?另外,我可以看到您使用了car和stone类,但我认为原始COCO数据集中不存在stone类。因此,我认为您可能需要对模型进行微调,使其了解如何识别石头。@PallaviJog OK!但是如何用我自己的图片来优化模型,你能给我一个教程或指南吗?很抱歉,我不知道.config文件(其中包含一些查找优化模型的参考)的工作方式。所以,我可能不会具体帮助你。但是你能告诉我你是从哪里得到这个.config文件的吗?我查看了github链接,没有找到任何可以找到它的培训文件夹。我还看到了.config文件中引用的某些pbtxt文件,其中包含模型的标签。我想您应该创建自己的带有2个标签的pbtxt文件。@PallaviJog您可以从models master/research/object\u detection/samples/configs中找到所有配置文件。ssd_mobilenet_v1_coco.config也在此文件夹中。我从以下网站下载了培训前的模型文件:“如果地图达到1,这不是最好的。如果地图达到0.48左右,它会非常强大”…听起来很有趣!你能解释一下原因吗?