classification sample asyncを詳しく

classification sample asyncで動作を学ぶ

Openvino toolkitをインストールした際にデモ実行するclassification sample asyncで詳しく見てみます

実行環境

CPU: Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz
MemTotal:       16318440 kB
OS: Ubuntu 16.04LTS

スクリプトを見る

通常は/opt/intel/openvino/deployment_tools/demo 内に格納されている、demo_squeezenet_download_convert_run.shの動作を確認します

スクリプトは5つのパートに分かれています

# Step 1. Download the Caffe model and the prototxt of the model

ビルド環境をaptでダウンロードします
そのため、sudoコマンドが走りますので権限が必要です

# Step 2. Configure Model Optimizer

caffeをダウンロードします

# Step 3. Convert a model with Model Optimizer

このステップでモデルを変換します

# Step 4. Build samples

ホームディレクトリにinference_engine_samples_buildと言うディレクトリを作成して、実行ファイルを作成します

# Step 5. Run samples

実際に実行する部分です

./classification_sample_async -d "$target" -i "$target_image_path" -m "${ir_dir}/${model_name}.xml" ${sampleoptions} 

プログラムの実行

実行部分だけを抜き出したプログラムで実行してみましょう

inference_engine_samples_build/intel64/Release/classification_sample_async -h
 [ INFO ] InferenceEngine: 
 API version ............ 2.1
 Build .................. 37988
 Description ....... API
 [ INFO ] Parsing input parameters
 

 classification_sample_async [OPTION]
 Options:
 

     -h                      Print a usage message.
     -i "<path>"             Required. Path to a folder with images or path to an image files: a .ubyte file for LeNetand a .bmp file for the other networks.
     -m "<path>"             Required. Path to an .xml file with a trained model.
       -l "<absolute_path>"  Required for CPU custom layers.Absolute path to a shared library with the kernels implementation
           Or
       -c "<absolute_path>"  Required for GPU custom kernels.Absolute path to the .xml file with kernels description
     -d "<device>"           Optional. Specify the target device to infer on (the list of available devices is shown below). Default value is CPU. Sample will look for a suitable plugin for device specified.
     -nt "<integer>"         Optional. Number of top results. Default value is 10.
     -p_msg                  Optional. Enables messages from a plugin 
 
 Available target devices:  CPU  GPU  MYRIAD 

ターゲットデバイスはCPU、GPU、MYRIAD(NCS2)が使用可能です
-dオプションによって設定可能です

プログラムの実行

inference_engine_samples_build/intel64/Release/classification_sample_async -d CPU -i /opt/intel/openvino/deployment_tools/demo/car.png -m /home/klf/openvino_models/ir/public/squeezenet1.1/FP16/squeezenet1.1.xml
 [ INFO ] InferenceEngine: 
 API version ............ 2.1
 Build .................. 37988
 Description ....... API
 [ INFO ] Parsing input parameters
 [ INFO ] Parsing input parameters
 [ INFO ] Files were added: 1
 [ INFO ]     /opt/intel/openvino/deployment_tools/demo/car.png
 [ INFO ] Creating Inference Engine
 CPU
 MKLDNNPlugin version ......... 2.1
 Build ........... 37988
 

 [ INFO ] Loading network files
 [ INFO ] Preparing input blobs
 [ WARNING ] Image is resized from (787, 259) to (227, 227)
 [ INFO ] Batch size is 1
 [ INFO ] Loading model to the device
 [ INFO ] Create infer request
 [ INFO ] Start inference (10 asynchronous executions)
 [ INFO ] Completed 1 async request execution
 [ INFO ] Completed 2 async request execution
 [ INFO ] Completed 3 async request execution
 [ INFO ] Completed 4 async request execution
 [ INFO ] Completed 5 async request execution
 [ INFO ] Completed 6 async request execution
 [ INFO ] Completed 7 async request execution
 [ INFO ] Completed 8 async request execution
 [ INFO ] Completed 9 async request execution
 [ INFO ] Completed 10 async request execution
 [ INFO ] Processing output blobs
 

 Top 10 results:
 

 Image /opt/intel/openvino/deployment_tools/demo/car.png
 

 classid probability label
 ------- ----------- -----
 817     0.6853030   sports car, sport car
 479     0.1835197   car wheel
 511     0.0917197   convertible
 436     0.0200694   beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
 751     0.0069604   racer, race car, racing car
 656     0.0044177   minivan
 717     0.0024739   pickup, pickup truck
 581     0.0017788   grille, radiator grille
 468     0.0013083   cab, hack, taxi, taxicab
 661     0.0007443   Model T
 

 [ INFO ] Execution successful
 

 [ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool inference_engine_samples_build/intel64/Release/classification_sample_async -d CPU -i /opt/intel/openvino/deployment_tools/demo/car.png -m /home/klf/openvino_models/ir/public/squeezenet1.1/FP16/squeezenet1.1.xml 

 [ INFO ] InferenceEngine: 
 API version ............ 2.1
 Build .................. 37988
 Description ....... API
 [ INFO ] Parsing input parameters
 [ INFO ] Parsing input parameters
 [ INFO ] Files were added: 1
 [ INFO ]     /opt/intel/openvino/deployment_tools/demo/car.png
 [ INFO ] Creating Inference Engine
 MYRIAD
 myriadPlugin version ......... 2.1
 Build ........... 37988
 

 [ INFO ] Loading network files
 [ INFO ] Preparing input blobs
 [ WARNING ] Image is resized from (787, 259) to (227, 227)
 [ INFO ] Batch size is 1
 [ INFO ] Loading model to the device
 [ INFO ] Create infer request
 [ INFO ] Start inference (10 asynchronous executions)
 [ INFO ] Completed 1 async request execution
 [ INFO ] Completed 2 async request execution
 [ INFO ] Completed 3 async request execution
 [ INFO ] Completed 4 async request execution
 [ INFO ] Completed 5 async request execution
 [ INFO ] Completed 6 async request execution
 [ INFO ] Completed 7 async request execution
 [ INFO ] Completed 8 async request execution
 [ INFO ] Completed 9 async request execution
 [ INFO ] Completed 10 async request execution
 [ INFO ] Processing output blobs
 

 Top 10 results:
 

 Image /opt/intel/openvino/deployment_tools/demo/car.png
 

 classid probability label
 ------- ----------- -----
 817     0.6708984   sports car, sport car
 479     0.1922607   car wheel
 511     0.0936890   convertible
 436     0.0216064   beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
 751     0.0075760   racer, race car, racing car
 656     0.0049667   minivan
 717     0.0027428   pickup, pickup truck
 581     0.0019779   grille, radiator grille
 468     0.0014219   cab, hack, taxi, taxicab
 661     0.0008636   Model T
 

 [ INFO ] Execution successful
 

 [ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool 

67%の確率でsports car, sport carと認識されています
ラベルに関しては、
/opt/intel/openvino/deployment_tools/demo/squeezenet1.1.labels 
で定義されています