You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **📢 Important Update**: The JSON2YOLO project is now integrated into the main Ultralytics package at https://github.com/ultralytics/ultralytics. The standalone scripts in this repository are no longer being actively updated. For the latest functionality, please use the new `convert_coco()` method described in our updated [data converter documentation](https://docs.ultralytics.com/reference/data/converter/).
15
+
14
16
## ⚙️ Requirements
15
17
16
18
To get started with JSON2YOLO, you'll need a [Python](https://www.python.org/) environment running version 3.8 or later. Additionally, you'll need to install all the necessary dependencies listed in the `requirements.txt` file. You can install these dependencies using the following [pip](https://pip.pypa.io/en/stable/) command in your terminal:
@@ -21,17 +23,25 @@ pip install -r requirements.txt # Installs all the required packages
21
23
22
24
## 💡 Usage
23
25
24
-
To convert your COCO JSON dataset to YOLO format, run the `convert.py` script from your terminal. You need to specify the path to the directory containing your COCO JSON annotation files and the directory where you want to save the resulting YOLO label files.
26
+
JSON2YOLO functionality is now part of the main `ultralytics` Python package. To use the converter, first install the package:
25
27
26
28
```bash
27
-
# Example usage: Convert COCO annotations to YOLO format
-`--json_dir`: Path to the directory containing COCO JSON annotation files (e.g., `instances_train2017.json`).
32
-
-`--save_dir`: Path to the directory where the converted YOLO label files (`.txt`) will be saved.
32
+
You can then easily convert COCO JSON datasets to YOLO format using the `convert_coco` method. Here's an example using keypoint annotations:
33
+
34
+
```python
35
+
from ultralytics.data.converter import convert_coco
36
+
37
+
convert_coco(
38
+
labels_dir="path/to/labels.json",
39
+
save_dir="path/to/output_dir",
40
+
use_keypoints=True,
41
+
)
42
+
```
33
43
34
-
This script will process the JSON files, extract bounding box information, and convert it into the YOLO format, saving one `.txt`file per image in the specified save directory. For more details on [dataset formats](https://docs.ultralytics.com/datasets/), refer to our documentation.
44
+
This method processes your JSON file, converts annotations (bounding boxes and keypoints), and saves the labels in YOLO format (`.txt`files) within the specified directory. For more details, refer to our [dataset format documentation](https://docs.ultralytics.com/datasets/).
0 commit comments