Open SamNew1 opened 6 years ago
Code:
def convert_labels(size, x1, y1, x2, y2):
"""
Definition: Parses label files to extract label and bounding box
coordinates. Converts (x1, y1, x1, y2) KITTI format to
(x, y, width, height) normalized YOLO format.
"""
def sorting(l1, l2):
if l1 > l2:
lmax, lmin = l1, l2
return lmax, lmin
else:
lmax, lmin = l2, l1
return lmax, lmin
xmax, xmin = sorting(x1, x2)
ymax, ymin = sorting(y1, y2)
dw = 1./size[1]
dh = 1./size[0]
x = (xmin + xmax)/2.0
y = (ymin + ymax)/2.0
w = xmax - xmin
h = ymax - ymin
x = x*dw
w = w*dw
y = y*dh
h = h*dh
return (x,y,w,h)
Decode:
x1, y1 = ((x + witdth)/2)*img_width, ((y + height)/2)*img_height
x2, y2 = ((x - witdth)/2)*img_width, ((y - height)/2)*img_height
@zuenko , thank you for your reply, short question, can I use yolo labelling data to train yolov2 and yolov3 directly? Are yolo, yolov2 and yolov3 using the data with the same format?
@Hanlin1233 I'm sure about v2, v3, but you can test yolo.cfg with COCO and figure out :-)
@zuenko , thanks!
Yes the format didn't change, you can also just open the yolov1 label file and check if it have the following format per line: classid x y w h Where x y w h are normalized to the image size, so you are able to find the label no matter how the image have been resized.
@TheMikeyR , thank you very much, got it!
Hello, does the yolo, yolov2 and yolov3 have the same data labelling format? can I use the yolo label data to train yolov3 directly?