11import argparse
2+ import json
23
34from detectionmetrics .datasets .goose import GOOSEImageSegmentationDataset
45
@@ -32,10 +33,19 @@ def parse_args() -> argparse.Namespace:
3233 required = True ,
3334 help = "Directory where dataset will be stored in common format" ,
3435 )
36+ parser .add_argument (
37+ "--new_ontology" ,
38+ type = str ,
39+ help = "New ontology JSON file name" ,
40+ )
41+ parser .add_argument (
42+ "--ontology_translation" ,
43+ type = str ,
44+ help = "Ontology translation JSON file name" ,
45+ )
3546 parser .add_argument (
3647 "--resize" ,
3748 type = str ,
38- required = False ,
3949 help = "Resize images to a specific size (e.g. 512x512)" ,
4050 )
4151
@@ -48,12 +58,26 @@ def main():
4858 """Main function"""
4959 args = parse_args ()
5060
61+ new_ontology , ontology_translation = None , None
62+ if args .new_ontology is not None :
63+ with open (args .new_ontology , "r" , encoding = "utf-8" ) as f :
64+ new_ontology = json .load (f )
65+
66+ if args .ontology_translation is not None :
67+ with open (args .ontology_translation , "r" , encoding = "utf-8" ) as f :
68+ ontology_translation = json .load (f )
69+
5170 dataset = GOOSEImageSegmentationDataset (
5271 train_dataset_dir = args .train_dataset_dir ,
5372 val_dataset_dir = args .val_dataset_dir ,
5473 test_dataset_dir = args .test_dataset_dir ,
5574 )
56- dataset .export (args .outdir , resize = args .resize )
75+ dataset .export (
76+ args .outdir ,
77+ resize = args .resize ,
78+ new_ontology = new_ontology ,
79+ ontology_translation = ontology_translation ,
80+ )
5781
5882
5983if __name__ == "__main__" :
0 commit comments