AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.64k stars 7.95k forks source link

yolo labelling data format #1279

Open SamNew1 opened 6 years ago

SamNew1 commented 6 years ago

Hello, does the yolo, yolov2 and yolov3 have the same data labelling format? can I use the yolo label data to train yolov3 directly?

zuenko commented 6 years ago

Yolo v2, v3

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
SamNew1 commented 6 years ago

@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?

zuenko commented 6 years ago

@Hanlin1233 I'm sure about v2, v3, but you can test yolo.cfg with COCO and figure out :-)

SamNew1 commented 6 years ago

@zuenko , thanks!

TheMikeyR commented 6 years ago

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.

SamNew1 commented 6 years ago

@TheMikeyR , thank you very much, got it!