尝试使用40x40px图像自定义训练MobilenetV2-训练后出现错误结果



我需要将小图像分类为4个不同的类别,+1"背景";用于错误检测。

在训练过程中,损失很快降至0.7,但即使走了80万步也会保持不变。最后,冻结图似乎可以用背景标签对大多数图像进行分类。

我可能遗漏了什么,我将在下面详细介绍我使用的步骤,欢迎任何反馈。我是tf slim的新手,所以这可能是一个明显的错误,也许样本太少了?我不是在寻找最高的精度,只是为原型设计工作。

可以在以下位置找到源材料:https://www.dropbox.com/s/k55xoygdzb2efag/TilesDataset.zip?dl=0

我在windows 10上使用了tensorflow gpu 1.15.3。


  • 我使用以下内容创建了数据集:python ./createTfRecords.py --tfrecord_filename=tilesV2_40 --dataset_dir=.tilesV2Tiles_40

  • 我在models master\research\slim\datasets中添加了一个基于flowers提供者的数据集提供者。

  • 我修改了master \ research \ slim \ nets \ mobilenet模型中的mobilenet_v2.py,更改了num_classes=5mobilenet.default_image_size=40

  • 我用python ./models-master/research/slim/train_image_classifier.py --model_name "mobilenet_v2" --learning_rate 0.045 --preprocessing_name "inception_v2" --label_smoothing 0.1 --moving_average_decay 0.9999 --batch_size 96 --learning_rate_decay_factor 0.98 --num_epochs_per_decay 2.5 --train_dir ./weight --dataset_name Tiles_40 --dataset_dir .tilesV2Tiles_40训练网络

  • 当我尝试这个python .models-masterresearchslimeval_image_classifier.py --alsologtostderr --checkpoint_path ./weight/model.ckpt-XXX --dataset_dir ./tilesV2/Tiles_40 --dataset_name Tiles_40 --dataset_split_name validation --model_name mobilenet_v2时,我得到了eval/Recall_5[1]eval/Accuracy[1]

  • 然后我用python .models-masterresearchslimexport_inference_graph.py --alsologtostderr --model_name mobilenet_v2 --image_size 40 --output_file .exportoutput.pb --dataset_name Tiles_40导出图形

  • freeze_graph --input_graph .exportoutput.pb --input_checkpoint .weightmodel.ckpt-XXX --input_binary true --output_graph .exportfrozen.pb --output_node_names MobilenetV2/Predictions/Reshape_1冷冻

  • 然后,我用python .label_image.py --graph .exportfrozen.pb --labels .tilesV2Tiles_40labels.txt --image .tilesV2Tiles_40photoslac1_1.png --input_layer input --output_layer MobilenetV2/Predictions/Reshape_1的数据集中的图像尝试网络这就是我分类错误的地方,如CCD_ 8;lac";数据集的图像


我尝试更改depth_multer、学习率、在cpu上学习,并从学习命令中删除--preprocessing_name "inception_v2"。我什么都不知道了。。。

改变你的学习率,也许从通常的3e-5开始。

最新更新