Skip to content

Commit 48c8f6c

Browse files
committed
Fix class id in yaml file.
1 parent 3a82a39 commit 48c8f6c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

general_json2yolo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ def convert_coco_json(json_dir='../coco/annotations/', use_segments=False, cls91
257257
categories_dict = {}
258258

259259
# Import json
260-
for json_file in sorted(Path(json_dir).resolve().glob('*.json')):
260+
for json_file in sorted(Path(json_dir).resolve().glob('*coco*.json')):
261261
fn = Path(save_dir) / 'labels' / json_file.stem.replace('instances_', '') # folder name
262262
fn.mkdir()
263263
with open(json_file) as f:
264264
data = json.load(f)
265265

266266
# Create categories_dict
267-
categories_dict = {item['id']: item['name'] for item in data['categories']}
267+
categories_dict = {item['id'] - 1: item['name'] for item in data['categories']}
268268

269269
# Create image dict
270270
images = {'%g' % x['id']: x for x in data['images']}
@@ -399,7 +399,7 @@ def delete_dsstore(path='../datasets'):
399399
source = 'COCO'
400400

401401
if source == 'COCO':
402-
convert_coco_json('../datasets/coco/annotations', # directory with *.json
402+
convert_coco_json(r'C:\Users\1000276203\OneDrive - Western Digital\SDSS_DPAOI_CV\data\pure_dataset_memory\new chipping', # directory with *.json
403403
use_segments=True,
404404
cls91to80=True)
405405

0 commit comments

Comments
 (0)