pylabel-project / pylabel

Python library for computer vision labeling tasks. The core functionality is to translate bounding box annotations between different formats-for example, from coco to yolo.
MIT License
313 stars 56 forks source link

not converting coco to yolo #21

Closed ashBabu closed 2 years ago

ashBabu commented 2 years ago

Hi, The code used

from pylabel import importer
path_to_annotations = "my_data/modified.json"
path_to_images = "/my_data/myVOC/JPEGImages/"
dataset = importer.ImportCoco(path=path_to_annotations, path_to_images=path_to_images, name="strawberry")
dataset.export.ExportToYoloV5(dataset)

The error msg says


Traceback (most recent call last):
  File "/home/ash/Ash/repo/object_detection/convert_coco2yolo/coco2yolo.py", line 5, in <module>
    dataset.export.ExportToYoloV5(dataset)
  File "/home/ash/anaconda3/envs/condaEnv3.8/lib/python3.8/site-packages/pylabel/exporter.py", line 434, in ExportToYoloV5
    path = PurePath(output_path)
  File "/home/ash/anaconda3/envs/condaEnv3.8/lib/python3.8/pathlib.py", line 651, in __new__
    return cls._from_parts(args)
  File "/home/ash/anaconda3/envs/condaEnv3.8/lib/python3.8/pathlib.py", line 683, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/home/ash/anaconda3/envs/condaEnv3.8/lib/python3.8/pathlib.py", line 667, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not Dataset
alexheat commented 2 years ago

Hello @ashBabu . I notice that you are passing the parameter dataset as a parameter to the ExportToYoloV5 command. It is necessary to pass the dataset object. Please see the documentation at https://pylabel.readthedocs.io/en/latest/pylabel.html#pylabel.exporter.Export.ExportToYoloV5

If you change the last line to this dataset.export.ExportToYoloV5() you should get some output and then you can customize it further.

ashBabu commented 2 years ago

thanks. It worked. Closing.