{{indexmenu_n>6}} ====== Semantic Segmentation ====== ここではOpenCVに実装された,領域分割(Semantic Segmentation)に関して使い方を解説します. object detectionでは短径領域(四角い領域)を使って,「どこになにがあるか?」を教えてくれる ものでしたが,segmentationは分割を指し,例えば下記のような出力をします.「どこになにがあるか?」 という問は変わりませんが,これがより詳細になり,「どのあたりになにがあるか?」までがわかるように なります. * このSegmentationをoFのaddonとしてまとめたものをgithubにおいています。 * https://github.com/TetsuakiBaba/ofxOpenCvDnnSegmentation {{:opencv_dnn:20180227180905.png?400|}} https://wiki.tum.de/display/lfdv/Image+Semantic+Segmentation OpenCVで確認できるセグメンテーションの手法として,下記の2つが利用できるのを確認しました. * FCN(Fully Conncected Network):https://github.com/shelhamer/fcn.berkeleyvision.org * 一般的な全結合型ネットワークを領域分割に応用したもの. * Enet:https://github.com/TimoSaemann/ENet * 領域分割をリアルタイム処理をするためのアルゴリズム ===== FCN ===== https://github.com/shelhamer/fcn.berkeleyvision.org に一通りの情報がまとまっています.このページではFCN-32s PASCAL を使ってみます.FCN-32s PASCALへのリンクをたどり次のサイトにいくといろいろデータもらえます. * {{ :opencv_dnn:fcn32s-heavy-pascal.caffemodel |}} * {{ :opencv_dnn:fcn32s-heavy-pascal.prototxt |}} * {{ :opencv_dnn:pascal-classes.txt |}} $ ./example_dnn_segmentation --classes=pascal-classes.txt --config=fcn8s-heavy-pascal.prototxt --model=fcn8s-heavy-pascal.caffemodel --width=500 --height=500 --rgb --mean=1 ===== Enet ===== 高速で動作可能な領域分割です.https://www.pyimagesearch.com/2018/09/03/semantic-segmentation-with-opencv-and-deep-learning/ も参考にすると良いでしょう. * {{ :opencv_dnn:categories.txt |}} * {{ :opencv_dnn:enet-model-best.net |}} $ ./example_dnn_segmentation enet --zoo=../../dnn/models.yml --classes=categories.txt --model=Enet-model-best.net --width=1024 --height=512 --rgb --mean=1 Enetを学習させるには下記のEnet作者による github ページを参照しましょう。 * https://github.com/TimoSaemann/ENet/tree/master/Tutorial * Reference * http://atkg.hatenablog.com/entry/2018/12/10/215224