前提・実現したいこと
TensorFlow Object Detection APIを使って独自データセットで学習をさせたいと考えています。
説明が足りないところは聞いていただければすぐに答えます。
2つの問題が生じていると考えています。
0. 学習ステップ数が0のまま。
0. 学習済みモデルを使えていない。
概要
時系列に沿って説明します。
機械学習自体が初めてなので、基本的には、
TensorFlow Object Detection API tutorialのとおりに実行しています。
1,[Installation]の頁
2,[Detect Objects Using Your Webcam]の頁
はデモが動くのでうまくいっていると思います。
3,Training Custom Object Detectorの頁
ここで問題が生じています。
tutorialと全く同じ名前のフォルダを、tutorialのとおりに配置しています。
trainning_demoフォルダの中身は
training_demo
├─ annotations (label_map.pbtxt, test.record, train.record, test_labels.csv, │ train_labels.csv)
├─ images (全画像+それぞれの画像の.xmlファイル)
│ ├─ test (test画像+それぞれの画像の.xmlファイル)
│ └─ train (train画像+それぞれの画像の.xmlファイル)
├─ pre-trained-model (ssd_inception_v2_coco_2018_01_28.tar.gzを解凍したもの)
├─ training (ssd_inception_v2_coco.config)
├─ train.py (TensorFlow/models/research/object_detection/legacy/train.pyをコピーしたもの)
pre-trained-modelフォルダには
[COCO-trained models]のssd_mobilenet_v2_cocoをDL, 解凍した中身
(checkpoint, frozen_inference_graph.pb, model.ckpt.data-00000-of-00001, model.ckpt.index, model.ckpt.meta,
pipeline.configという各種ファイル + saved_modelというフォルダ)が入っています。
画像は20枚で1枚の画像に3-6つラベルしています。
ラベルは1種類です。
すべて.jpg形式で300x400 pix程度です。
train画像16枚、test画像4枚に分けました。
trainingフォルダにあるファイルは
ssd_inception_v2_coco.configを改変したものです。
変更したのは
num_classes: 90から1へ
train_configの
fine_tune_checkpoint:, input_path:, label_map_path:
eval_configの
input_path:, label_map_path:
をフルパスで指定しています。
model { ssd { num_classes: 1 box_coder { ・・・・・・・・・・・・・・・・・・・・・・・・・・・・ 省略します ・・・・・・・・・・・・・・・・・・・・・・・・・・・・ } } 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: 3 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 } } } } } feature_extractor { type: 'ssd_inception_v2' 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, } } override_base_feature_extractor_hyperparams: true } 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: 24 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: "C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\pre-trained-model\model.ckpt" from_detection_checkpoint: true num_steps: 200000 data_augmentation_options { random_horizontal_flip { } } data_augmentation_options { ssd_random_crop { } } } train_input_reader: { tf_record_input_reader { input_path: "C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\annotations\train.record" } label_map_path: "C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\annotations\label_map.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: "C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\annotations\test.record" } label_map_path: "C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\annotations\label_map.pbtxt" shuffle: false num_readers: 1 }
tutorial通りに
train.pyが入っているTensorFlow\workspace\training_demoのディレクトリに移動し、
以下のコマンドを実行しました。
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_inception_v2_coco.config
するとエラーを吐き出します。
発生している問題・エラーメッセージ
WARNING:root:Variable [FeatureExtractor/InceptionV2/Conv2d_1a_7x7/BatchNorm/beta/ExponentialMovingAverage] is not available in checkpoint WARNING:root:Variable [FeatureExtractor/InceptionV2/Conv2d_1a_7x7/BatchNorm/beta/RMSProp] is not available in checkpoint ・・・・・・ 似たようなメッセージが延々続くため、かなり省略。 ・・・・・・ WARNING:root:Variable [FeatureExtractor/InceptionV2/Mixed_5c_2_Conv2d_5_3x3_s2_128/weights/RMSProp] is not available in checkpoint WARNING:root:Variable [FeatureExtractor/InceptionV2/Mixed_5c_2_Conv2d_5_3x3_s2_128/weights/RMSProp_1] is not available in checkpoint
試したこと
学習済みのモデルと今のモデルが合っていないのではないかと、DLからやり直しましたが駄目でした。
別のモデルのペアでやっても似たようなメッセージが出ます。
しばらく別のメッセージの後、次のメッセージが出ます。
name: GeForce RTX 2080 major: 7 minor: 5 memoryClockRate(GHz): 1.83 pciBusID: 0000:17:00.0 totalMemory: 8.00GiB freeMemory: 6.55GiB 2019-09-03 16:13:53.388657: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 1 with properties: name: GeForce RTX 2080 major: 7 minor: 5 memoryClockRate(GHz): 1.83 pciBusID: 0000:65:00.0 totalMemory: 8.00GiB freeMemory: 6.55GiB 2019-09-03 16:13:53.406710: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0, 1 2019-09-03 16:13:54.905149: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-09-03 16:13:54.914554: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0 1 2019-09-03 16:13:54.918857: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N N 2019-09-03 16:13:54.923367: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 1: N N 2019-09-03 16:13:54.926699: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6294 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080, pci bus id: 0000:17:00.0, compute capability: 7.5) 2019-09-03 16:13:54.940144: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 6294 MB memory) -> physical GPU (device: 1, name: GeForce RTX 2080, pci bus id: 0000:65:00.0, compute capability: 7.5) INFO:tensorflow:Restoring parameters from C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\pre-trained-model\model.ckpt INFO:tensorflow:Restoring parameters from C:\Users\SakuLab2\Documents\TensorFlow\workspace\training_demo\pre-trained-model\model.ckpt INFO:tensorflow:Running local_init_op. INFO:tensorflow:Running local_init_op. INFO:tensorflow:Done running local_init_op. INFO:tensorflow:Done running local_init_op. INFO:tensorflow:Starting Session. INFO:tensorflow:Starting Session. INFO:tensorflow:Saving checkpoint to path training/model.ckpt INFO:tensorflow:Saving checkpoint to path training/model.ckpt INFO:tensorflow:Starting Queues. INFO:tensorflow:Starting Queues. INFO:tensorflow:global_step/sec: 0 INFO:tensorflow:global_step/sec: 0 INFO:tensorflow:Recording summary at step 0. INFO:tensorflow:Recording summary at step 0.
これで終了してしまいます。
期待している以下のようなメッセージが出てきません。
INFO:tensorflow:global step 1: loss = 13.8886 (12.339 sec/step)
...
TensorBoardでtotallossなどを確認しても
1点しかでてきません。
これは1回しかステップをおこなっていないということでしょうか?
補足情報
OS : windows10
CPU : Intel(R)Core(TM)i9-9900X CPU @ 3.50GHz
RAM : 128 GB
64bit OS
グラボ :ZOTAC GAMING GeForce RTX 2080 AMP Edition (2台)
tensorflow-gpu 1.12.0
CUDA V9.0.176
cuDNN v7.1.3
tutorialではtensorflow-gpu 1.9, cuDNN v7.0.5でしたが
そのままではデモでエラーが出るので、指示どおりにupしました。
回答2件
あなたの回答
tips
プレビュー