From bea27f3f9db11736113dde9f3502c0c947f263d7 Mon Sep 17 00:00:00 2001 From: yuedongli1 Date: Tue, 6 Jun 2023 17:52:04 +0800 Subject: [PATCH] fix --- examples/finetune_SHWD/convert_shwd2yolo.py | 6 ++++++ mindyolo/utils/config.py | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/finetune_SHWD/convert_shwd2yolo.py b/examples/finetune_SHWD/convert_shwd2yolo.py index d0d2bd19..0b3d1259 100644 --- a/examples/finetune_SHWD/convert_shwd2yolo.py +++ b/examples/finetune_SHWD/convert_shwd2yolo.py @@ -172,6 +172,7 @@ def xml2json(image_index, xml_path): parser.add_argument('--root_dir', default='', type=str, help='root directory of data set') opt = parser.parse_args() + # generate directory structure root_dir = opt.root_dir new_dir = os.path.join(root_dir, '..', 'SHWD') os.makedirs(os.path.join(new_dir, 'images', 'train')) @@ -194,15 +195,19 @@ def xml2json(image_index, xml_path): if not os.path.exists(old_path): old_path = os.path.join(images_path, stem + '.JPG') + # copy image to new path new_images_path = os.path.join(new_dir, 'images', 'train') shutil.copy(old_path, new_images_path) + # rename image_file to continuous number old_name = Path(old_path).name new_stem = str(image_index).zfill(8) os.rename(os.path.join(new_images_path, old_name), os.path.join(new_images_path, new_stem + '.jpg')) + # write relative path to train.txt train_txt_yolo.write('./images/train/' + new_stem + '.jpg' + '\n') + # convert xml file to txt file xml_path = os.path.join(labels_path, stem + '.xml') txt_path = os.path.join(new_dir, 'labels', 'train', new_stem + '.txt') xml2txt(xml_path, txt_path) @@ -230,6 +235,7 @@ def xml2json(image_index, xml_path): txt_path = os.path.join(new_dir, 'labels', 'val', new_stem + '.txt') xml2txt(xml_path, txt_path) + # convert xml file to json file xml2json(image_index, xml_path) image_index += 1 diff --git a/mindyolo/utils/config.py b/mindyolo/utils/config.py index ad681202..0b35a893 100644 --- a/mindyolo/utils/config.py +++ b/mindyolo/utils/config.py @@ -113,7 +113,6 @@ def __init__(self, cfg_dict): super(Config, self).__init__() for k, v in cfg_dict.items(): setattr(self, k, Config(v) if isinstance(v, dict) else v) - self.__dict__.update(cfg_dict) def __setattr__(self, name, value): self[name] = value