centerpoint.yaml
모델, pv_rcnn.yaml
모델 2종류로 각각 학습을 진행하였다Car 0.00 0 -1.59 553.89 184.63 598.47 220.55 1.26 1.60 3.56 -1.39 1.73 27.81 -1.64
Car 0.00 0 -1.49 502.27 183.99 537.52 210.78 1.37 1.63 3.57 -4.95 2.00 39.72 -1.61
Car 0.00 0 2.52 837.66 190.04 921.14 223.55 1.38 1.35 3.30 11.95 2.18 32.11 2.87
Car 0.00 0 2.24 955.63 189.82 1046.94 226.08 1.59 1.73 4.02 18.79 2.44 34.70 2.73
Van 0.00 2 -1.61 560.17 165.84 585.44 198.47 2.26 1.64 5.20 -2.79 1.81 52.88 -1.66
DontCare -1 -1 -10 486.65 171.90 546.07 186.53 -1 -1 -1 -1000 -1000 -1000 -10
def xyxy2xywh_np(bbox, img_width, img_height):
min_x, min_y, max_x, max_y = np.array(bbox, dtype=np.float32)
center_x = round((max_x + min_x) / 2,2)
center_y = round((max_y + min_y) / 2,2)
bbox_width = round(max_x - min_x,2)
bbox_height = round(max_y - min_y,2)
yolo_x = center_x / img_width
yolo_y = center_y / img_height
yolo_width = bbox_width / img_width
yolo_height = bbox_height / img_height
bbox = (yolo_x, yolo_y, yolo_width, yolo_height)
return bbox
class convert2yolo():
def __init__(self):
self.label_dir = "./kitti_labels/val/"
self.img_dir = "./images/"
self.img_train_dir = self.img_dir + "val/"
# self.img_valid_dir = self.img_dir + "valid/"
self.output_dir = "./labels/val/"
self.class_names = {
'Car' : 0,
'Van' : 1,
'Truck' : 2,
'Pedestrian' : 3,
'Person_sitting' : 4,
'Cyclist' : 5,
'Tram' : 6,
'Misc' : 7,
'DontCare' : 8
}
self.label_dir_list = glob(self.label_dir + "/*")
os.makedirs(self.output_dir, exist_ok=True)
def save(self):
for file in self.label_dir_list:
img_path = file.split('/')[-1].split('.')[0]
img_name = self.img_train_dir + img_path + ".png"
img = cv2.imread(img_name, cv2.IMREAD_ANYCOLOR)
img_width = img.shape[1]
img_height = img.shape[0]
yolo_file = open(self.output_dir + file.split("/")[-1],"w+")
with open(file, 'r', encoding='UTF-8') as f:
lines = f.readlines()
for line in lines:
line = line.split(' ')
class_id = self.class_names[line[0]]
cx, cy, w, h = xyxy2xywh_np(line[4:8], img_width, img_height)
yolo_file.write(f"{class_id} {cx} {cy} {w} {h}\n")
f.close()
yolo_file.close()
if __name__ == "__main__":
convert = convert2yolo()
convert.save()
$ https://github.com/WongKinYiu/yolov7.git
$ docker run -it --ipc=host --gpus all -v /home/ubuntu/yolov7/:/workspace/yolov7 -v /home/ubuntu/KITTI/:/workspace/KITTI -p 8888:8888 --name yolov7 nvcr.io/nvidia/pytorch:21.12-py3
📦KITTI
┣ 📂images
┃ ┣ 📂train
┃ ┣ 📂val
┃ ┗ 📂test
┣ 📂labels
┃ ┣ 📂train
┃ ┗ 📂val
┣ 📜train.txt : 전체 경로를 포함한 이미지 경로 리스트
┣ 📜val.txt
┗ 📜test.txt
# ls | while read file; do echo "$(pwd)/$file"; done > ../train.txt
# apt update
# apt install -y zip htop screen libgl1-mesa-glx
# pip install seaborn thop
# cd /yolov7
# pip install -r requirements.txt
train : /workspace/KITTI/train.txt
val : /workspace/KITTI/val.txt
test : /workspace/KITTI/test.txt
# number of classes
nc: 9
# class names
names: ['Car', 'Van', 'Truck', 'Pedestrian', 'Person_sitting', 'Cyclist', 'Tram', 'Misc', 'DontCare']
python train.py --workers 8 --device 0 --batch-size 16 --data data/coco.yaml --img 640 640 --cfg cfg/training/yolov7.yaml --weights '' --name yolov7 --hyp data/hyp.scratch.p5.yaml
# python detect.py --weight ./runs/train/yolov7/weights/best.pt --conf 0.25 --img-size 640 --source /workspace/KITTI/images/test/000002.png