open_model_zoo / mask_rcnn_demoをデバッグします
前の記事に続いて、DEMOがコンパイルされた後、OpenVINOで遊んで、open_model_zooでモデルを試してみましょう。
open_model_zooで特定のモデルをデバッグするとします(次のコマンドでは、使用するモデルを使用します。通常、複数を同時に変換し、ランダムテストを終了します)。
まず、オプティマイザーの作業を完了し、モデルを変換してIRファイルを取得します。
コマンドは次のとおりです
python mo_tf.py --input_model
E:/mask_rcnn_resnet50_atrous_coco_2018_01_28/frozen_inference_graph.pb
--tensorflow_use_custom_operations_config extensions/front/tf/mask_rcnn_support.json
--tensorflow_object_detection_api_pipeline_config E:/mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28/pipeline.config
vscodeでデバッグしたい友達は、以下のlaunch.jsonファイルを見ることができます。
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"--input_model","E:\\mask_rcnn_resnet50_atrous_coco_2018_01_28\\frozen_inference_graph.pb",
"--tensorflow_use_custom_operations_config","D:/devOpenVino/openvino_2020.3.194/deployment_tools/model_optimizer/extensions/front/tf/mask_rcnn_support.json",
"--tensorflow_object_detection_api_pipeline_config","E:/mask_rcnn_inception_resnet_v2_atrous_coco_2018_01_28/pipeline.config"
]
}
]
}
私のように出力ファイル名を指定しなかった場合、変換後に取得できるのはfrozen_inference_graph.binファイルとfrozen_inference_graph.xmlファイルだけです。対応するモデルファイル名に変更するように注意してください。変更しないと、混乱する可能性があります。たくさんの。
以下では、VS2019のC ++デモでこれらのモデルのテストを開始します。これらのデモは、前回の講義「OpenVINO_cppサンプルのコンパイルで遊ぶ」でコンパイルされたので、使用できるようになりました。
パス1を追加
デバッグバージョンを使用する場合は、環境変数のパスパス設定を追加します
C:\ IntelSWTools \ openvino_2020.3.194 \ deployment_tools \ inference_engine \ bin \ intel64 \ Debug
同時に、opencv_world430d.dllをこのフォルダーにコピーします(コピーしたくない場合は、とにかく自分でパスを追加して、プログラムにdllファイルを見つけさせることができます)
リリースバージョンの場合は、追加します
C:\ IntelSWTools \ openvino_2020.3.194 \ Deployment_tools \ inference_engine \ bin \ intel64 \ Release、
同時に、opencv_world430.dllをこのフォルダーにコピーします
一般に、Intelineference_engineによって使用される多くのdllファイルがあります。
パス2を追加
追加する必要のあるパスもいくつかありますが、
C:\ IntelSWTools \ openvino_2020.3.194 \ deployment_tools \ inference_engine \ external \ tbb \ bin
C:\ IntelSWTools \ openvino_2020.3.194 \ Deployment_tools \ ngraph \ lib
試運転
実行中のプロジェクトの名前はmask_rcnn_demoです。
詳細については、https://docs.openvinotoolkit.org/latest/_demos_mask_rcnn_demo_README.htmlを参照してください。
説明の一部を次のように抜粋します(注:これはLinuxでの形式であり、以下の説明で使用される形式はWindowsシステムでの形式であり、コマンドの使用方法に少し違いがあります)
./mask_rcnn_demo -h
InferenceEngine:
API version ............ <version>
Build .................. <number>
mask_rcnn_demo [OPTION]
Options:
-h Print a usage message.
-i "<path>" Required. Path to a .bmp image.
-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 implementations.
Or
-c "<absolute_path>" Required for GPU custom kernels. Absolute path to the .xml file with the kernels descriptions.
-d "<device>" Optional. Specify the target device to infer on (the list of available devices is shown below). Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The demo will look for a suitable plugin for a specified device (CPU by default)
-detection_output_name "<string>" Optional. The name of detection output layer. Default value is "reshape_do_2d"
-masks_name "<string>" Optional. The name of masks layer. Default value is "masks"
ヘルプドキュメントを表示します:mask_rcnn_demo --h
C:\IntelSWTools\openvino_2020.3.194\deployment_tools\open_model_zoo\demos\dev\intel64\Debug>mask_rcnn_demo --h
InferenceEngine: 00007FFCC7C49BC8
mask_rcnn_demo [OPTION]
Options:
-h Print a usage message.
-i "<path>" Required. Path to a .bmp image.
-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 implementations.
Or
-c "<absolute_path>" Required for GPU custom kernels. Absolute path to the .xml file with the kernels descriptions.
-d "<device>" Optional. Specify the target device to infer on (the list of available devices is shown below). Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The demo will look for a suitable plugin for a specified device (CPU by default)
-detection_output_name "<string>" Optional. The name of detection output layer. Default value is "reshape_do_2d"
-masks_name "<string>" Optional. The name of masks layer. Default value is "masks"
Available target devices: CPU GNA
ここの画像はbmp形式である必要があります。
写真の住所を入力するにはどうすればよいですか?正式な注文は次のとおりです。
./mask_rcnn_demo -i <path_to_image>/inputImage.bmp -m <path_to_model>/mask_rcnn_inception_resnet_v2_atrous_coco.xml
実際、コマンドライン入力方式を使用すると、OpenVINOはargs_helper.hppというファイルによって処理され、1つのセクションのコードは次のようになります。
/**
* @brief This function find -i/--images key in input args
* It's necessary to process multiple values for single key
* @return files updated vector of verified input files
*/
inline void parseInputFilesArguments(std::vector<std::string> &files) {
std::vector<std::string> args = gflags::GetArgvs();
bool readArguments = false;
for (size_t i = 0; i < args.size(); i++) {
if (args.at(i) == "-i" || args.at(i) == "--images") {
readArguments = true;
continue;
}
if (!readArguments) {
continue;
}
if (args.at(i).c_str()[0] == '-') {
break;
}
readInputFilesArguments(files, args.at(i));
}
}
つまり、入力画像の形式は次のいずれかになります。
-ixyz.bmpまたは--images <慎重に検討していません。ここにフォルダーまたはxyz.bmpがあります>
VS2019でデバッグおよび実行している場合は、プロジェクトのデバッグパラメータを上記の形式に直接設定できます。たとえば、次のようになります。
-i J:\BigData\default.bmp -m E:\mask_rcnn_resnet50_atrous_coco_2018_01_28\frozen_inference_graph.xml
純粋なCPUでこのDEBUGモードを試しましたが、非常に低速でした。リリースモードでは、ランダムに写真を見つけて数秒かかりましたが、スピードアップを感じることができません。
もちろん、まだ熟考すべきことがたくさんあります。これらの詳細については、当面はここでは取り上げません。最初に試してみましょう。