前提・実現したいこと
画像から説明文を生成するためのTensorflow内のオープンソース「Show and Tell」をCPUで実行しようとしています。
Show and Tellに関するGoogleの記事
以下の3つのページを見ながら作業しています。
今回はCPU環境での生成なので3番目が中心です。
発生している問題・エラーメッセージ
CPU環境でキャプションを生成した記事に沿って、
- 「Show and Tell」Tensorflow実装コードのダウンロード
- Inception v3 の導入
- トレーニング済みモデルの準備
- キャプション生成
を行いました。キャプション生成までは、エラーは起きず、スムーズに進んでいます。
4.キャプション生成でエラーが発生してしまい、他のGPU環境で実装されている記事を読んでも解決できていない状況です。
キャプション生成させたい画像ファイルをrun_inference バイナリを実行するところで、
tensorflow.python.framework.errors_impl.NotFoundError: ~/test/M/models/research/im2txt/word_counts.txt; No such file or directory
該当のソースコード
「キャプション生成させたい画像ファイルをrun_inference バイナリを実行する」部分のコードです
bash
1~/test/models/research/im2txt/bazel-bin/im2txt/run_inference \ 2--checkpoint_path="~/test/M/models/research/im2txt/model.ckpt-2000000" \ 3--vocab_file="~/test/M/models/research/im2txt/word_counts.txt" \ 4--input_files="~/test/M/models/research/im2txt/im2txt/cat.jpg"
試したこと
エラー文では、Mフォルダがないというエラーが出ていたので、Mフォルダのないコマンドで試したところ、
さらに別のエラーが出て、解決できませんでした。
bash
1$ test/models/research/im2txt/bazel-bin/im2txt/run_inference --checkpoint_path="test/models/research/im2txt/model.ckpt-2000000" --vocab_file="test/models/research/im2txt/word_counts.txt" --input_files="test/models/research/im2txt/im2txt/cat.jpg"
エラー文
NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error: Key lstm/basic_lstm_cell/bias not found in checkpoint [[node save/RestoreV2 (defined at /Users/username/Desktop/show_and_tell/test/models/research/im2txt/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/inference_utils/inference_wrapper_base.py:116) = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
inference_wrapper_base.pyの中身(116行目前後抜粋)
python
1 def build_graph_from_config(self, model_config, checkpoint_path): 2 """Builds the inference graph from a configuration object. 3 4 Args: 5 model_config: Object containing configuration for building the model. 6 checkpoint_path: Checkpoint file or a directory containing a checkpoint 7 file. 8 9 Returns: 10 restore_fn: A function such that restore_fn(sess) loads model variables 11 from the checkpoint file. 12 """ 13 tf.logging.info("Building model.") 14 self.build_model(model_config) 15 saver = tf.train.Saver() #116行目 16 17 return self._create_restore_fn(checkpoint_path, saver)
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
MacOS mojave
tensorflow 1.12.0
numpy 1.15.4
Babel 2.3.4
Python 3.6.0 :: Anaconda 4.3.0 (x86_64)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。