diff --git a/.convert.py.swo b/.convert.py.swo new file mode 100644 index 0000000..3295891 Binary files /dev/null and b/.convert.py.swo differ diff --git a/.convert.py.swp b/.convert.py.swp new file mode 100644 index 0000000..f59ceb6 Binary files /dev/null and b/.convert.py.swp differ diff --git a/LabelMeYoloConverter b/LabelMeYoloConverter new file mode 160000 index 0000000..d4c0590 --- /dev/null +++ b/LabelMeYoloConverter @@ -0,0 +1 @@ +Subproject commit d4c05906cb342c7821b3dc923151a9ef3e2fd7fe diff --git a/convert.py b/convert.py index 10a1d70..6b3c1d0 100644 --- a/convert.py +++ b/convert.py @@ -14,17 +14,21 @@ from os import walk, getcwd from PIL import Image +#Changed the convert function so it can extract the bounding boxes coordinates +#for using it with Yolov5. + def convert(size, box): - dw = 1./size[0] - dh = 1./size[1] - x = (box[0] + box[1])/2.0 - y = (box[2] + box[3])/2.0 - w = box[1] - box[0] - h = box[3] - box[2] - x = x*dw - w = w*dw - y = y*dh - h = h*dh + x = round((b[0] + b[1])/2, 5) # b_center_x + y = round((b[2] + b[3])/2, 5) #b_center_y + w = round((b[1] - b[0]), 5) #b_width + h = round((b[3] - b[2]), 5) #b_height + +# Normalise the co-ordinates by the dimensions of the image + image_w, image_h = size + x /= image_w #b_center_x + y /= image_h #b_center_y + w /= image_w #b_width + h /= image_h #b_height return (x,y,w,h) diff --git a/convert.py.swp b/convert.py.swp new file mode 100644 index 0000000..e69de29 diff --git a/converter.py b/converter.py new file mode 100644 index 0000000..e69de29