AI Research Topic/Object Detection

[Object Detection] 객체 탐지를 위한 데이터 주석 Yolo 형식으로 변환하기

꾸준희 2019. 8. 19. 16:07
728x90
반응형

 

 

 

 

https://github.com/ssaru/convert2Yolo

 

ssaru/convert2Yolo

This project purpose is convert voc annotation xml file to yolo-darknet training file format - ssaru/convert2Yolo

github.com

 

 

 

위 깃허브 저장소에서 아래와 같은 데이터 세트들의 주석 파일을 Yolo 프레임워크에 맞게 변환 할 수 있다. 

  • COCO
  • VOC
  • UDACITY Object Detection
  • KITTI 2D Object Detection

 

 

필자는 person.names 를 생성하고, 

COCO 데이터 세트의 (train2017, val2017) 이미지 정보가 담긴  json 주석 파일들을

yolo 형식(txt)에 맞춰 변경하였다. 

 

$ python3 example.py
--datasets COCO
--img_path /dataset/COCO/val2017/ 
--label /dataset/COCO/annotations/instances_val2017.json 
--convert_output_path /dataset/YOLO/ 
--img_type ".jpg" 
--manipast_path ./ 
--cls_list_file /dataset/COCO/coco80.names
  • img_path : val2017 이나 train2017 을 다운받은 폴더
  • label : 해당 데이터에 대한 주석 파일
  • convert_output_path : txt  파일들을 저장할 공간
  • img_type : COCO 영상 확장자
  • manipast_path : 변환된 파일들의 리스트를 manipast.txt 로 저장할 폴더
  • cls_list_file : COCO 클래스 이름들이 담긴 파일 

 

이 때 cls_list_file 은 다음과 같은 리스트를 이용하였다. 

person
bicycle
car
motorcycle
airoplane
bus
train
truck
boat
traffic light
fire hydrant
stop sign
parking meter
bench
bird
cat
dog
horse
sheep
cow
elephant
bear
zebra
giraffe
backpack
umbrella
handbag
tie
suitcase
frisbee
skis
snowboard
sports ball
kite
baseball bat
baseball glove
skateboard
surfboard
tennis racket
bottle
wine glass
cup
fork
knife
spoon
bowl
banana
apple
sandwich
orange
broccoli
carrot
hot dog
pizza
donut
cake
chair
sofa
potted plant
bed
dining table
toilet
tv
laptop
mouse
remote
keyboard
cell phone
microwave
oven
toaster
sink
refrigerator
book
clock
vase
scissors
teddy bear
hair drier
toothbrush

 

왜냐하면 darknet 깃에 포함되어있는 coco.names 의 이름과 원래 coco 데이터 상 이름이 약간 상이하기 때문이다.

 

참고자료 

https://github.com/ssaru/convert2Yolo/issues/18

 

Why an extra 6 classes? · Issue #18 · ssaru/convert2Yolo

I saw that in a previous github issue, 6 classes had to be added to the 80 existing classes in the coco.names list (though they are only rewordings of objects already in the dataset): motorcycle po...

github.com

 

 

변경한 000000001000.txt 파일 내역은 다음과 같다. (필자는 사람 클래스 0을 남겨두고 나머지 클래스를 제외함)

0 0.245 0.555 0.13 0.476
0 0.663 0.298 0.058 0.095
0 0.484 0.529 0.139 0.658
0 0.405 0.623 0.156 0.519
0 0.894 0.7 0.211 0.6
0 0.731 0.717 0.18 0.566
0 0.664 0.666 0.138 0.665
0 0.581 0.648 0.13 0.654
0 0.711 0.349 0.138 0.252
0 0.361 0.537 0.15 0.568
0 0.128 0.607 0.093 0.443
0 0.587 0.29 0.082 0.086

728x90
반응형