0
0

More than 3 years have passed since last update.

Tensorflow Object Detection API でモデルの評価

Last updated at Posted at 2021-02-11

手順

・検証データはpipeline.configのeval_input_readerに記述しておきます。

pipeline.config

eval_input_reader {
  label_map_path: "/content/drive/My Drive/signate/label_map.pbtxt"
  shuffle: false
  num_epochs: 1
  tf_record_input_reader {
    input_path: "data/eval.tfrecords"
  }
}

・トレーニングと同じ「model_main_tf2.py」をチェックポイントディレクトリ(トレーニングで生成されたもの)に追加して、実行。
*GPUありでの実行のみサポートしています。


python object_detection/model_main_tf2.py \
   --pipeline_config_path="my_model_dir/pipeline.config" \
   --model_dir="/content/drive/My Drive/signate/checkpoint" \
   --checkpoint_dir="/content/drive/My Drive/signate/checkpoint" 

出力

こういうのがプリントされます。

Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.011
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.037
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.002
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.007
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.016
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.022
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.076
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.128
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.070
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.168

IoUの意味についてはこちら:
【IOU】 Object Detection の性能指標【I/U】

precision:正解と予測したもののうち、実際正解だったものの割合
recall:実際の正解のうち、正解と予測できたものの割合

チェックポイントディレクトリに検証イベントファイルが生成され、Tensorboardで使用できます。
トレーニング後でも評価できますし、トレーニング中に別のターミナルでトレーニング・チェックポイントにアクセスして実行すると、
トレーニングによって新しいチェックポイントが生成されるのを待って、最新のチェックポイントで同時評価していくことができます。

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLを使ったアプリを作っています。
機械学習関連の情報を発信しています。

Twitter
Medium

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0