JSON2YOLO icon indicating copy to clipboard operation
JSON2YOLO copied to clipboard

where is the convert.py??

Open my-littledarling opened this issue 9 months ago • 10 comments

my-littledarling avatar Apr 07 '25 14:04 my-littledarling

Hello! The converter.py file is part of the main ultralytics package. You can find the source code directly on GitHub within the ultralytics/data/converter.py file.

pderrenger avatar Apr 07 '25 22:04 pderrenger

python.exe .\converter.py --json_dir E:\Pycharm_cache\datasets\攀爬\coco\person_keypoints_val2017.json --save_dir E:\Pycharm_cache\datasets\攀爬\coco\labels

运行没反应的

Image

guopeizhao avatar May 19 '25 08:05 guopeizhao

Hi @guopeizhao,

It appears you're trying to run the converter.py file directly, but it's not meant to be executed this way. Instead, you should use the Python API by importing the convert_coco function from the ultralytics package.

Here's how to properly convert your COCO annotations to YOLO format:

from ultralytics.data.converter import convert_coco

# For keypoints data (like person_keypoints_val2017.json)
convert_coco(
    labels_dir="E:/Pycharm_cache/datasets/攀爬/coco/",  # Directory containing your json file
    save_dir="E:/Pycharm_cache/datasets/攀爬/coco/labels",
    use_keypoints=True  # Since you're using keypoints data
)

Run this code as a Python script or in a Python interpreter, not as a direct command line execution of the converter.py file.

pderrenger avatar May 19 '25 13:05 pderrenger

The Readme needs to be adjusted. It's not correctly described there.

Hapyr avatar May 22 '25 10:05 Hapyr

Hi @Hapyr,

You're absolutely right. The README in this repository needs updating to reflect the current implementation. The JSON2YOLO functionality has been integrated into the main Ultralytics package and improved significantly.

For anyone looking to convert COCO format to YOLO, please use the convert_coco() function from the main package as documented in the Ultralytics data converter reference documentation. The standalone converter scripts in this repository are deprecated.

Thank you for pointing this out - we'll update the README to prevent further confusion.

pderrenger avatar May 22 '25 16:05 pderrenger

@Hapyr could you please submit a PR for README updates? Thank you!

glenn-jocher avatar May 22 '25 23:05 glenn-jocher

Alright, PR #122 should point this out.

Hapyr avatar May 26 '25 09:05 Hapyr

Thank you @Hapyr for submitting PR #122! That will help clarify the current state of the conversion tools and direct users to the proper implementation in the main ultralytics package.

pderrenger avatar May 26 '25 12:05 pderrenger

I think since PR #122 is merged now, this issue can be closed.

Hapyr avatar Jul 17 '25 01:07 Hapyr

Agreed! With PR #122 merged and the README updated to clarify that the conversion functionality is now in the main ultralytics package, this issue is resolved. Thank you for your contribution @Hapyr!

pderrenger avatar Jul 17 '25 15:07 pderrenger