diff --git a/ppdet/data/tools/x2coco.py b/ppdet/data/tools/x2coco.py index bf67b359f92e3bc2221c02585cde8cc59dc57a7b..5e4e5d46e98d38c8fa167d8ed06f0b536693cbbc 100644 --- a/ppdet/data/tools/x2coco.py +++ b/ppdet/data/tools/x2coco.py @@ -132,7 +132,7 @@ def deal_json(ds_type, img_path, json_path): image_num = -1 object_num = -1 for img_file in os.listdir(img_path): - img_label = img_file.split('.')[0] + img_label = os.path.splitext(img_file)[0] if img_file.split('.')[ -1] not in ['bmp', 'jpg', 'jpeg', 'png', 'JPEG', 'JPG', 'PNG']: continue @@ -282,13 +282,16 @@ def main(): indent=4, cls=MyEncoder) if args.val_proportion != 0: - val_data_coco = deal_json(args.output_dir + '/val', args.json_input_dir) + val_data_coco = deal_json(args.dataset_type, + args.output_dir + '/val', + args.json_input_dir) val_json_path = osp.join(args.output_dir + '/annotations', 'instance_val.json') json.dump( val_data_coco, open(val_json_path, 'w'), indent=4, cls=MyEncoder) if args.test_proportion != 0: - test_data_coco = deal_json(args.output_dir + '/test', + test_data_coco = deal_json(args.dataset_type, + args.output_dir + '/test', args.json_input_dir) test_json_path = osp.join(args.output_dir + '/annotations', 'instance_test.json')