提交 9cbc2591 编写于 作者: S SunAhong1993 提交者: qingqing01

Update x2coco.py (#135)

上级 b8fc8e6c
...@@ -227,7 +227,8 @@ def main(): ...@@ -227,7 +227,8 @@ def main():
print('The image folder does not exist!') print('The image folder does not exist!')
os._exit(0) os._exit(0)
try: try:
assert args.train_proportion + args.val_proportion + args.test_proportion == 1.0 assert abs(args.train_proportion + args.val_proportion \
+ args.test_proportion - 1.0) < 1e-5
except AssertionError as e: except AssertionError as e:
print( print(
'The sum of pqoportion of training, validation and test datase must be 1!' 'The sum of pqoportion of training, validation and test datase must be 1!'
...@@ -255,15 +256,18 @@ def main(): ...@@ -255,15 +256,18 @@ def main():
count = 1 count = 1
for img_name in os.listdir(args.image_input_dir): for img_name in os.listdir(args.image_input_dir):
if count <= train_num: if count <= train_num:
if osp.exists(args.output_dir + '/train/'):
shutil.copyfile( shutil.copyfile(
osp.join(args.image_input_dir, img_name), osp.join(args.image_input_dir, img_name),
osp.join(args.output_dir + '/train/', img_name)) osp.join(args.output_dir + '/train/', img_name))
else: else:
if count <= train_num + val_num: if count <= train_num + val_num:
if osp.exists(args.output_dir + '/val/'):
shutil.copyfile( shutil.copyfile(
osp.join(args.image_input_dir, img_name), osp.join(args.image_input_dir, img_name),
osp.join(args.output_dir + '/val/', img_name)) osp.join(args.output_dir + '/val/', img_name))
else: else:
if osp.exists(args.output_dir + '/test/'):
shutil.copyfile( shutil.copyfile(
osp.join(args.image_input_dir, img_name), osp.join(args.image_input_dir, img_name),
osp.join(args.output_dir + '/test/', img_name)) osp.join(args.output_dir + '/test/', img_name))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册