Wrong coordinates of Darknet Annotations (CLIPPED)
Opened this issue · 0 comments
Deleted user commented
I have downloaded your data set Darknet Annotations (CLIPPED)
, but I found that the coordinates of cx
, cy
are wrong, and the label value is only 1/2 of the real value, and rely on the following script to convert:
import os
dirs = [
"/path/to/train2017", "/path/to/val2017"
]
for di in dirs:
labels = os.listdir(di)
for label_file in labels:
lb_path = os.path.join(di, label_file)
with open(lb_path, "r") as f:
labels = f.readlines()
new_labels = []
for label in labels:
id, cx, cy, w, h = map(float, label.split())
id = str(int(id))
x = 2*(cx-w/2)
y = 2*(cy-h/2)
ncx = x+w/2
ncy = y+h/2
vals = [id, str(ncx), str(ncy), str(w), str(h)]
new_labels.append(" ".join(vals)+"\n")
with open(lb_path, "w") as f:
f.writelines(new_labels)