Skip to content

Commit

Permalink
fix split_odvg.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaAndroid committed Nov 16, 2023
1 parent 6bbe134 commit 3c92aff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/misc/split_odvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ def parse_args():
'out_dir',
type=str,
help='The output directory of coco semi-supervised annotations.')
parser.add_argument('--label-map-file', '-m', type=str, help='label map file')
parser.add_argument(
'--num-img',
'-n',
default=200,
type=int,
help='num of extract image, -1 means all images')
Expand Down Expand Up @@ -58,10 +60,18 @@ def main():
progress_bar.update()

out_path = os.path.join(args.out_dir, args.ann_file)
out_dir = os.path.dirname(out_path)
mkdir_or_exist(out_dir)

with jsonlines.open(out_path, mode='w') as writer:
writer.write_all(data_list[:num_img])

if args.label_map_file is not None:
out_dir = os.path.dirname(os.path.join(args.out_dir, args.label_map_file))
mkdir_or_exist(out_dir)
shutil.copyfile(os.path.join(args.data_root, args.label_map_file),
os.path.join(args.out_dir, args.label_map_file))


if __name__ == '__main__':
main()

0 comments on commit 3c92aff

Please sign in to comment.