The Beautiful Future

SSD 본문

논문

SSD

Small Octopus 2017. 12. 14. 10:48

1. MS COCO 학습데이터 준비하기

1.1 annotation 다운로드

** MS COCO 사이트에서 다운로드

instances_train-val2014.zip

instances_train2014.json

instances_val2014.json

image_info_test2014.zip

 image_info_test2014.json

image_info_test2015.zip

 image_info_test2015.json

 image_info_test-dev2015.json


** https://github.com/rbgirshick/py-faster-rcnn/tree/master/data 여기서 다운로드

https://dl.dropboxusercontent.com/s/s3tw5zcg7395368/instances_valminusminival2014.json.zip?dl=0 : instances_valminusminval2014.json.zip

https://dl.dropboxusercontent.com/s/o43o90bna78omob/instances_minival2014.json.zip?dl=0 : instances_minval2014.json.zip


1.2. image 다운로드

2014 Training images [80k/13GB]

2014 Val. images [40k/6.2GB]

2014 Testing images [40k/6.2GB]

2015 Testing images [80k/12.4G]


1.3. 디렉토리 설정

$HOME/data/coco 디렉토리 생성

~/coco/annotations 디렉토리 생성 + annotations 파일 옮기기

~/coco/images 디렉토리 생성 + images 파일 옮기기


1.4 annotation 파일 변형

** 변환 프로그램 준비

git clone https://github.com/weiliu89/coco.git

cd coco

git checkout dev

cd PythonAPI

python setup.py build_ext --inplace


** annotation 변환

# Check scripts/batch_split_annotation.py and change settings accordingly.

# ~/data/coco/Annotation/ 에 DB 구분별 이미지별 json 파일을 만들어줌

# test2014, test2015, train2014, val2014, minival2014, valminusminival2014, test-dev2015로 폴더 구별 만들어줌

# minival2014의 의미는 val2014에서 5000장을 뽑은 셋 의미

# valminusminival2014은 minival2014을 뺀 나머지 val2014를 의미

# test2015 81434장 중 20288장을 뽑은 것

# coco/PythonAPI/scripts/batch_split_annotation.py

python scripts/batch_split_annotation.py


# Create the minival2014_name_size.txt and test-dev2015_name_size.txt in $CAFFE_ROOT/data/coco

# . 작은 밸리데이션을 의미 파일 안에는 

# 이미지 번호, 높이, 넓이 순으로 적힘

# batch_get_image_size.py 파일안에 CAFFE 경로를 바꿔줄것

python scripts/batch_get_image_size.py


1.5 LMDB 만들기

** DB 별 리스트 만들기

# Create the minival.txt, testdev.txt, test.txt, train.txt in $CAFFE_ROOT/data/coco/

# 각 파일에는 이미지위치와 json위치가 쌍으로 한줄씩 적힘.

cd $CAFFE_ROOT

python data/coco/create_list.py


** 실제 DB 만들기

caffe-ssd를 보면 build/tools/convert_annoset 이 있는데 이게 리스트를 읽어 실제 LMDB를 만들어준다. 

명령어는 아래와 같다.

./convert_annoset --anno_type=detection --label_type=json --label_map_file=$CAFFE_ROOT/data/coco/labelmap_coco.prototxt --check_label=True --min_dim=0 --max_dim=0 --resize_height=0 --resize_width=0 --backend=lmdb --shuffle=False --check_size=False --encode_type=jpg --encoded=True --gray=False /home/user/data/coco/ $CAFFE_ROOT/data/coco/train.txt /home/user/data/coco/lmdb/coco_train_lmdb

명령어를 살펴보면

--anno_type=detection

어노테이션 타입이 디텍션.

--label_type=json

레이블 타입이 json

--label_map_file=$CAFFE_ROOT/data/coco/labelmap_coco.prototxt

레이블 맵파일 지정. 실제 보면 아래와 같은 형식으로 81개 클래스가 정리되어있다.

item {

  name: "1"

  label: 1

  display_name: "person"

}

--check_label=True

레이블의 정합성 체크, 똑같은게 중복 되는지...

--min_dim=0 --max_dim=0

0으로 설정 되지 않았을 경우 영상을 scaling한다. 영상의 크기가 조절 됨.

min_dim은 최소의 디멘션을 의미하며 이미지의 H W중 작은게 최소 min_dim이되게 스케일을 계산

그다음 이미지의 H W중 큰값을 스케일 해보고 max_dim 보다 크면 max_dim에 맞게 스케일을 계산

--resize_height=0 --resize_width=0 

min_dim, max_dim이 설정 되어있지 않은 경우 resize_height, resize_width로 일괄 크기 변화

만약 0이면 원 영상 크기 그대로 사용.

--backend=lmdb

lmdb로 디비만듬.

--shuffle=False

디비에 저장 순서를 섞을 것인가

--check_size=False

실제 이미지와 json파일에 적혀있는 이미지 크기가 같은가.

--encode_type=jpg --encoded=True --gray=False

실제 이미지 포멧, 디비에 이포멧으로 정장됨, 인코딩 되어있는지, 그레이영상으로 변환할지.

/home/user/data/coco/

이미지 리스트 앞에 붙어서 영상을 불러올 폴더

$CAFFE_ROOT/data/coco/train.txt

이미지와 json anno 정보 리스트 파일

/home/user/data/coco/lmdb/coco_train_lmdb

db가 저장될 곳.




'논문' 카테고리의 다른 글

OpenPose: Real-time Multi-Person 2D Pose Estimation using Part Affinity Fields  (0) 2020.06.07
ICCV 2019  (0) 2019.11.14
PRUNING FILTERS FOR EFFICIENT CONVNETS, ICLR2017  (0) 2017.06.09
MDM  (0) 2017.03.16
Residual Net  (0) 2016.12.12
Comments