()
| 120 | |
| 121 | |
| 122 | def main(): |
| 123 | parser = argparse.ArgumentParser( |
| 124 | description='This script support converting voc format xmls to coco format json') |
| 125 | parser.add_argument('--ann_dir', type=str, default=None, |
| 126 | help='path to annotation files directory. It is not need when use --ann_paths_list') |
| 127 | parser.add_argument('--ann_ids', type=str, default=None, |
| 128 | help='path to annotation files ids list. It is not need when use --ann_paths_list') |
| 129 | parser.add_argument('--ann_paths_list', type=str, default=None, |
| 130 | help='path of annotation paths list. It is not need when use --ann_dir and --ann_ids') |
| 131 | parser.add_argument('--labels', type=str, default=None, |
| 132 | help='path to label list.') |
| 133 | parser.add_argument('--output', type=str, default='output.json', help='path to output json file') |
| 134 | parser.add_argument('--ext', type=str, default='', help='additional extension of annotation file') |
| 135 | args = parser.parse_args() |
| 136 | label2id = get_label2id(labels_path=args.labels) |
| 137 | ann_paths = get_annpaths( |
| 138 | ann_dir_path=args.ann_dir, |
| 139 | ann_ids_path=args.ann_ids, |
| 140 | ext=args.ext, |
| 141 | annpaths_list_path=args.ann_paths_list |
| 142 | ) |
| 143 | convert_xmls_to_cocojson( |
| 144 | annotation_paths=ann_paths, |
| 145 | label2id=label2id, |
| 146 | output_jsonpath=args.output, |
| 147 | extract_num_from_imgid=True |
| 148 | ) |
| 149 | |
| 150 | |
| 151 | if __name__ == '__main__': |
no test coverage detected