facenetロードpretrained_Modelエラー問題解決

6347 ワード

facenetロードpretrained_Modelエラー問題解決
に質問
facenet githubアドレス:https://github.com/davidsandberg/facenetfacenet自己トレーニングモデルを使用して中断した後、プログラムを実行します.
//     
python3 src/train_softmax.py --pretrained_models models/20190303-192600/ --       
新聞を誤る注意:models/20190303-192600は、前回自分でモデルを保存するために訓練したフォルダです.
の原因となる
Facenetプログラムはtfを呼び出した.train.Saverクラスは、プリトレーニングモデルをロードする際にSaverを使用する.restore(sess,pretrained_model)メソッドは、models/20190303-192600/model-20190303-192600の2番目の変数を入力すべきである.ckpt-6の文字列.models/20190303-192600フォルダの下の内容を比較すると、正しく入力されたパラメータは、事前トレーニングモデルフォルダの下のファイルを指していないことがわかります.models/20190303-192600フォルダの下の内容:
zzd@zzd-ubuntu-K80:20190303-192600$ ls
checkpoint
model-20190303-192600.ckpt-4.data-00000-of-00001
model-20190303-192600.ckpt-4.index
model-20190303-192600.ckpt-5.data-00000-of-00001
model-20190303-192600.ckpt-5.index
model-20190303-192600.ckpt-6.data-00000-of-00001
model-20190303-192600.ckpt-6.index
model-20190303-192600.meta
解決策
方法1:プログラムの実行を続行するときに正しいパラメータを入力すればよい.
//     
python3 src/train_softmax.py --pretrained_models models/20190303-192600/model-20190303-192600.ckpt-6 --       
方法2:修正:src/train_softmax.py 201行目の後に行を追加し、元の202行を変更します.変更後:
200             if pretrained_model:
201                 print('Restoring pretrained model: %s' % pretrained_model)
202                 ckpt = tf.train.get_checkpoint_state(os.path.dirname(pretrained_model))
203                 saver.restore(sess, ckpt.model_checkpoint_path))
この方法では、プログラムを実行し続けるときに、事前トレーニングモデルが存在するフォルダのパスを入力するだけで実行できます.
//     
python3 src/train_softmax.py --pretrained_models models/20190303-192600/ --       
終わります.