LoginSignup
26
31

More than 3 years have passed since last update.

アノテーションツール labelme を使ってsemantic segmentation用の学習データを作る

Last updated at Posted at 2019-10-18

目的

U-netでsemantic segmentationをするために学習データを作る。
私はubuntu18を使っているのですが、windowsで作業する人もいるので両方で環境構築しました。

また、結局使わないことになりましたが、webベースのsemantic segmentation editorもインストールして使ってみたので、そのインストール方法もおまけで末尾に

環境

windows10
Gforce 1050ti
メモリ8GB (この環境でlabelmeを使うと度々固まるので増設します…)

ubuntu18.04
Gforce 1080ti
メモリ 8GB×2

lablmeのインストール

[github] https://github.com/wkentaro/labelme
基本このInstallation通りにやりました。

windows

anacondaが必要なのでpython3.7verをインストールしておきます。
[Anaconda] https://www.anaconda.com/distribution/
環境PATHは推奨されてないけどチェックしておいたほうが便利

コマンドプロンプトかPowershellを開いて以下のコマンド

conda create --name=labelme python=3.6
pip install labelme
conda install pillow=4.0.0

おわり。

後はlabelmeとコマンドを打てば起動します。

labelme

ubuntu18.04

私のubuntuちゃんにはpython2系と3系の両方があるので、python3でインストールします。

sudo apt-get install python3-pyqt5  # PyQt5
sudo pip3 install labelme

おわり。

このコマンドでlabelmeのGUIが起動します。

labelme

ラベル名を一括で設定する方法は分かりませんでした。
どのファイル編集すればいいんだろ?

囲い終わるとポップアップでラベルの入力画面が出てくるので、そこでラベル名を入力できます。
1度入力すれば記憶され、次からはそれを選べるようになります。

いっぱいラベルがある場合は面倒かもしれません・・・

簡単すぎて書くまでもなかった

のでsemantic segmentation editorのインストールについて

semantic segmentation editorのインストール

こちらはLinuxかOSXのみ対応のweb上でアノテーションできるツールです。
ただ社外秘のデータなどを扱う場合は、サーバーを立てるかした方がよいかもしれません。

[gituhub] https://github.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor

以下のコマンドでMeteorをインストール

curl https://install.meteor.com/ | sh

するとこんな形で返ってきます。途中パスワードを求められます。

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7784    0  7784    0     0   8978      0 --:--:-- --:--:-- --:--:--  8978
Downloading Meteor distribution
######################################################################## 100.0%

Meteor 1.8.1 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.
[sudo] okubo18 のパスワード: 

To get started fast:

  $ meteor create ~/my_cool_app
  $ cd ~/my_cool_app
  $ meteor

Or see the docs at:

  docs.meteor.com

次にsemantic-segmentation-editorのソースコードをDLして解凍しておきます。
https://github.com/Hitachi-Automotive-And-Industry-Lab/semantic-segmentation-editor/releases
DLしたディレクトリでアプリケーションを起動。

tar -zxvf semantic-segmentation-editor-1.1.4.tar.gz 
cd semantic-segmentation-editor-1.1.4
meteor npm install
meteor npm start

ここで結構時間がかかりました。
http://localhost:3000にアクセスするとtar.gzファイルと一緒にDLされたサンプルファイルのアノテーションができるようになっています。

settings.json

これを編集すれば参照するディレクトリやラベルの色、名前が変更できます。

おわりに

最終的にlabelmeを選んだ理由は、

  • UIがシンプルで使いやすそう
  • web版じゃない(機密データがあるので)
  • 出力が.jsonファイルだけど.pngに変換する機能がある

U-netの学習には、教師データとしてpngの画像が必要だったので、1番下は重要ポイントでした。
semantic segmentation editorは自動でpng画像は保存されるものの、画像のヘッダーを調べると、アノテーション情報が含まれて無さそうだったが微妙ポイントでした。
.jsonファイルとセットで使わないといけないのかな?
でも、肝心の.jsonファイルは自動で保存されない仕様になっているっぽく、わざわざ表示させてコピペしなきゃいけない感じ。

設定を変えれば色々できるかもですが、面倒なのでやめました。

26
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
31