It's a tool can help you convert COCO format to YOLO format.
By two steps:
- Convert
COCO.json
toxml
- Convert
xml
toyolo.txt
# Download the repo
git clone https://github.com/DanielHo-BS/coco2yolo.git
cd coco2yolo
# Install python library
pip install -r requirements.txt
-
Create
classes.txt
with Classes which you want find.Text Table ...... Title Footnote
-
Setting PATH in
coco2xml.py
COCO_ANNOTATIONS_PATH = '/COCO/train.json' COCO_IMAGES_DIRECTORY = '/PNG/' EXTRACTED_SAVING_PATH = '/train_coco_format/' CLASS_TXT = '/classes.txt' # Classes which you want to find
-
Setting PATH in
xml2yolo.py
#Setting relative path LABEL_PATH = '/train_coco_format/' IMAGE_PATH = '/train_coco_format/' SAVE_PATH = '/train_yolo_format/'
-
Setting LABEL of classes in
xml2yolo.py
# Setting Label of Classse by Using dictionary status_dic = { 'Text':0, 'Table':1, 'Picture':2, 'Page-header':3, 'Page-footer':4 }
-
Run in termainal
# First way: ./main.sh # Seconud way: python coco2xml.py python xml2yolo.py
-
See the result by
drew_bbox.py
-
Setting PATH in
drew_bbox.py
imageFolder = "test_yolo_format/image/" labelFolder = "test_yolo_format/label/"
-
Run in termainal
python drew_bbox.py
-
If get error when run ./main.sh
:
chmod a+x main.sh