使用x2coco.py转换数据集时,找不到命名形如 xxx.xxx.jpg 的图片对应的label文件
Created by: FibonacciSun
版本:0.1.0
x2coco.py转换自有dataset, type为labelme 数据集的label目录中,有文件命名为 1569478414.73587.json
运行出现如下错误
Traceback (most recent call last): File "../PaddleDetection/ppdet/data/tools/x2coco.py", line 300, in main() File "../PaddleDetection/ppdet/data/tools/x2coco.py", line 276, in main args.dataset_type, args.output_dir + '/train', args.json_input_dir) File "../PaddleDetection/ppdet/data/tools/x2coco.py", line 142, in deal_json with open(label_file) as f: FileNotFoundError: [Errno 2] No such file or directory: 'json_annotation/1569478414.json'
原因是取jpg文件的文件名时,只考虑了文件名符合 .jpg 的情况,对于. *. jpg 这种就不支持了,对应地也就找不到label文件
--- a/ppdet/data/tools/x2coco.py +++ b/ppdet/data/tools/x2coco.py @@ -132,7 +132,8 @@ 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]