前回はNVDLAを使ってCaffeのモデルを実行してみた。 ただし実行結果が分からないので何とか解析できるようにしたい。
nvdla_runtime
の実行オプションには--rawdump
オプションがあるので、これを使えば実行後の結果をダンプできるらしい。
# ./nvdla_runtime --help Usage: ./nvdla_runtime [-options] --loadable <loadable_file> where options include: -h print this help message -s launch test in server mode --image <file> input jpg/pgm file --normalize <value> normalize value for input image --mean <value> comma separated mean value for input image --rawdump dump raw dimg data
実行後に、output.dimg
を参照すると結果を見ることができる。
# ./nvdla_runtime --loadable ../lenet/basic.nvdla --rawdump --image ../lenet/digits/one.pgm ... [33150.014288] reset engine done Work Found! Work Done Shutdown signal received, exiting Test pass # cat output.dimg 1 0 0 0 0 0 0 0 0 0
結果を見てみるとone.bgm
なので1の結果が出てほしいのだけれども、インデックス0、つまり1が判定されている。
one.bgm
を参照すると、白黒逆転じゃない?NVDLAのGitHub Issueにも同じような話が出ていた。
本物のMNISTを使わないとだめだな。
MNISTのテストデータをBGMに変換する
MNISTのデータはバイナリで提供されているので、それをBGMに変換しなければならない。
MNISTのデータのダウンロードとBGMへの変換は、以下のサイトを参考にした。
これだけではテキストタイプのBGMなので、ImageMagickを使ってバイナリに変換する。
$ convert 0.pgm +compress conv_0.pgm $ convert 1.pgm +compress conv_1.pgm
図. conv_0.pgmの出力 (5の画像)
図. conv_1.pgmの出力 (0の画像)
変換したBGMを使って、再度NVDLAを実行した。
# ./nvdla_runtime --loadable ../lenet/basic.nvdla --rawdump --image ../lenet/image/conv_0.pgm ... # cat output.dimg 0 0 0 0 0 1 0 0 0 0 #
conv_0.pgm(5の画像)については正しく認識できたようだ。次に、conv_1.pgm(0の画像)の認識に挑戦する。
# ./nvdla_runtime --loadable ../lenet/basic.nvdla --rawdump --image ../lenet/image/conv_1.pgm ... # cat output.dimg 1 0 0 0 0 0 0 0 0 0 #
こちらも正しく認識できた。