0

I have dataset in the form bbox "2947 1442 40 40" I want to convert it into YoloV5 format. I don't know exactly how can I can convert this notation to YOLOv5.

3 Answers3

1

Example:

  • Image properties: width=1156 pix, height=1144 pix.
  • bounding box properties: xmin=1032, ymin=20, xmax=1122, ymax=54, object_name="Ring".
  • Let objects_list="bracelet","Earring","Ring","Necklace"

YOLOv5 format: f"{category_idx} {x1 + bbox_width / 2} {y1 + bbox_height / 2} {bbox_width} {bbox_height}\n"

  • $bbox_{width} = x_{max}/width - x_{min}/width = (1122-1032)/1156 = 0.07785467128027679$
  • $bbox_{height} = y_{max}/height - y_{min}/height = (54-20)/1144 = 0.029720279720279717$
  • $x_{center}=x_{min}/width+bbox_{width}/2 = 0.9316608996539792$
  • $y_{center}=y_{min}/height + bbox_{height}/2 = 0.032342657342657344$
  • category_idx=2
  • Final result: 2 0.9316608996539792 0.032342657342657344 0.07785467128027679 0.029720279720279717
Illustrati
  • 311
  • 1
  • 9
0

You don't have quite enough information to convert that annotation to Yolo.

The yolo format looks like this

0 0.588196 0.474138 0.823607 0.441645
<class-label x_center_image y_center_image width height>

There is a clear description of what the values mean here https://stackoverflow.com/a/66563144/5183735.

So in order to convert your annotations you will also need to know the class-label and the height and width of your image.

If you have those things let me know and I may be able to provide more help. Also do you know what tool created those annotations? There be other documentation on how to convert annotations of that type.

alexheat
  • 479
  • 5
  • 9
0

You can try to import images with labels in Roboflow, then export them in Yolov5 PyTorch format.

ramy
  • 1
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 09 '22 at 21:02