computervisioneng / pose-detection-keypoints-estimation-yolov8

GNU Affero General Public License v3.0
37 stars 12 forks source link

ValueError: not enough values to unpack (expected 3, got 0) #4

Open ACanFirat opened 11 months ago

ACanFirat commented 11 months ago

I have an issue while training

sample txt file: """ 0 0.48935185185185187 0.4830729166666667 0.8268518518518518 0.2671875 0.1425925925925926 0.3578125 0.862037037037037 0.36614583333333334 0.8851851851851852 0.6052083333333333 0.0962962962962963 0.5989583333333334 """

yaml file: """ path: path_to_data/front_side
 train: images/train
 val: images/val

 kpt_shape: [4, 2]
 # 2 cause of there are just x and y flip_idx: [0, 1, 2, 3]

 names:

0: front_side
 """

train.py: """ from ultralytics import YOLO


 model = YOLO("yolov8n-pose.pt") model.train(data=r"path_to_yaml\dataset.yaml", epochs=200, imgsz=640, project="front_side_keypoint") """

""" in get_labels len_cls, len_boxes, len_segments = (sum(x) for x in zip(*lengths)) ValueError: not enough values to unpack (expected 3, got 0) """

I did as same as video while I am watching but I got this error. Can you please help me about it?

I run it on A5000 and ultralytics: 8.0.83

sangeun-jo commented 11 months ago

modify line 44 of CVAT_to_cocoKeypoints.py as below.

label_file.write('{} {} {}'.format(p[0] / width, p[1] / height, 2))

Then convert to coco keypoint foramt and try again.

Zulfiquar15 commented 6 months ago

import os from xml.dom import minidom out_dir = './out' if not os.path.exists(out_dir): os.makedirs(out_dir) file = minidom.parse('annotations.xml') images = file.getElementsByTagName('image') for image in images: name = image.getAttribute('name') width = int(image.getAttribute('width')) height = int(image.getAttribute('height')) bbox = image.getElementsByTagName('box')[0] xtl = int(float(bbox.getAttribute('xtl'))) ytl = int(float(bbox.getAttribute('ytl'))) xbr = int(float(bbox.getAttribute('xbr'))) ybr = int(float(bbox.getAttribute('ybr'))) w = xbr - xtl h = ybr - ytl label_file = open(os.path.join(out_dir, name[:-4] + '.txt'), 'w') label_file.write('0 {} {} {} {} '.format(str((xtl + (w / 2)) / width), str((ytl + (h / 2)) / height), str(w / width), str(h / height))) keypoints = image.getElementsByTagName('points') keypoints_list = [] for point in keypoints: point_coords = point.attributes['points'].value.split(',') keypoints_list.append((int(float(point_coords[0])), int(float(point_coords[1])))) for kp in keypoints_list: label_file.write('{} {} {} '.format(kp[0] / width, kp[1] / height, 2)) label_file.close()