Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yuedongli1 committed Jun 6, 2023
1 parent 9746f6c commit bea27f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/finetune_SHWD/convert_shwd2yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion mindyolo/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bea27f3

Please sign in to comment.