C:\>git clone https://github.com/tzutalin/labelImg.git
C:\>pip install PyQt5
C:\>pip install lxml
C:\>cd labelImg
C:\labelImg>pyrcc5 –o libs/resources.py resources.qrc
labelImg
├─ data
└─ predefined_classes.txt
VOC | YOLO |
---|---|
import cv2
def annotation(images = "image_sozai.jpg", templates = "template_sozai.jpg"):
template = cv2.imread(templates)
image = cv2.imread(images)
h, w = image.shape[:2]
map_cc = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
_, max_val, _, max_loc = cv2.minMaxLoc(map_cc)
center = (max_loc[0] + template.shape[1]/2, max_loc[1] + template.shape[0]/2)
str_pos = "0 {:7f} {:7f} {:7f} {:7f}\n".format(center[0]/w, center[1]/h, template.shape[1]/w, template.shape[0]/h)
with open(images[:-4] + ".txt","a") as f:
f.write(str_pos)
if __name__ == "__main__":
annotation()
yolov5
├─ data.yaml
├─ train
│ ├─ images
│ │ └─ *.jpg
│ ├─ labels
│ └─ *.txt
├─ valid
├─ images
│ └─ *.jpg
├─ labels
└─ *.txt
C:\yolov5>python train.py --data data.yaml --cfg models/hub/yolov5n6.yaml --weights "" --batch-size 8 --epochs 300
yolov5
├── runs
├── train
├── exp
├── weights
├── best.pt
└── last.pt
labelimgのインストール方法と使い方
https://laid-back-scientist.com/labelimg
YOLOv5を使った物体検出
https://www.alpha.co.jp/blog/202108_02