cvl-robot's diary

研究ノート メモメモ https://github.com/dotchang/

OpenCV3.4.2で始める浅いディープラーニング (その4 セマンティックセグメンテーション)

2.example_dnn_segmentation.exe

意味づけ領域塗分け

Use this script to run classification deep learning networks using OpenCV.
Usage: example_dnn_classification.exe [params]

--backend (value:0)
Choose one of computation backends: 0: automatically (by default), 1: Halide language (http://halide-lang.org/), 2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), 3: OpenCV implementation
-c, --config
Path to a text file of model contains network configuration. It could be a file with extensions .prototxt (Caffe), .pbtxt (TensorFlow), .cfg (Darknet)
--classes
Optional path to a text file with names of classes.
-f, --framework
Optional name of an origin framework of the model. Detect it automatically if it does not set.
-h, --help
Print help message.
--height
Preprocess input image by resizing to a specific height.
-i, --input
Path to input image or video file. Skip this argument to capture frames from a camera.
-m, --model
Path to a binary file of model contains trained weights. It could be a file with extensions .caffemodel (Caffe), .pb (TensorFlow), .t7 or .net (Torch), .weights (Darknet)
--mean
Preprocess input image by subtracting mean values. Mean values should be in BGR order and delimited by spaces.
--rgb
Indicate that model works with RGB input images instead BGR ones.
--scale (value:1)
Preprocess input image by multiplying on a scale factor.
--target (value:0)
Choose one of target computation devices: 0: CPU target (by default), 1: OpenCL, 2: OpenCL fp16 (half-float precision), 3: VPU
--width
Preprocess input image by resizing to a specific width.

実行例

ENet

Enet-model-best.netというファイルはあるのだけれど、使い方が分からない・・・。

example_dnn_segmentation.exe --scale=0.00392 --width=1024 --height=512 --mean=0 0 0 --rbg --model=Enet-model-best.net --input=dog416.png --classes=enet-classes.txt

f:id:cvl-robot:20180723193448p:plainf:id:cvl-robot:20180723193500p:plain
ENetによるセマンティックセグメンテーション

FCN8s

example_dnn_segmentation.exe --model=fcn8s-heavy-pascal.caffemodel --config=fcn8s-heavy-pascal.prototxt --scale=1.0 --width=500 --height=500 --mean=0 0 0 --input=dog416.png

f:id:cvl-robot:20180719220835p:plain

classesに与える適切なファイルが分からない。色分けは21色でされるのに、おそらく対応するラベルファイルのobject_detection_classes_pascal_voc.txtの登録数が20なので数が合わないとして無視される。仕方ないので、segmentation_classes_pascal_voc.txtをobject_detection_pascal_voc.txtのコピーとして作って、頭に一行「Unlabeled」を足す。

example_dnn_segmentation.exe --model=fcn8s-heavy-pascal.caffemodel --config=fcn8s-heavy-pascal.prototxt --scale=1.0 --width=500 --height=500 --mean=0 0 0 --input=dog416.png --classes=segmentation_classes_pascal_voc.txt

f:id:cvl-robot:20180719225943p:plain