Last active
          November 15, 2023 19:20 
        
      - 
      
- 
        Save johncf/4f74f73217653fe34b2a8586a1ad50b6 to your computer and use it in GitHub Desktop. 
Revisions
- 
        johncf revised this gist Nov 15, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import pickle from zipfile import ZipFile # from https://github.com/onnx/models/blob/8d50e3f/vision/classification/imagenet_val_maps.pklz with gzip.open('imagenet_val_maps.pklz', 'rb') as f: dirs, mappings = pickle.load(f) src_dir = "ILSVRC/Data/CLS-LOC/val" 
- 
        johncf revised this gist Nov 15, 2023 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,12 +13,14 @@ path_map[os.path.join(src_dir, m[0])] = os.path.join(target_dir, m[1], m[0]) # from https://www.kaggle.com/competitions/imagenet-object-localization-challenge/data with ZipFile('imagenet-val.zip', 'w') as ozf: with ZipFile('imagenet.zip', 'r') as zf: dirs = set() for path in zf.namelist(): if path.startswith("ILSVRC/Data/CLS-LOC/val/"): newpath = path_map[path] ozf.writestr(newpath, zf.read(path)) elif path == "LOC_synset_mapping.txt": ozf.writestr(f"ILSVRC/synset_mapping.txt", zf.read(path)) elif path == "LOC_val_solution.csv": ozf.writestr(f"ILSVRC/val_loc.csv", zf.read(path)) 
- 
        johncf created this gist Nov 15, 2023 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import os.path import gzip import pickle from zipfile import ZipFile # from https://github.com/onnx/models/blob/main/vision/classification/imagenet_val_maps.pklz with gzip.open('imagenet_val_maps.pklz', 'rb') as f: dirs, mappings = pickle.load(f) src_dir = "ILSVRC/Data/CLS-LOC/val" target_dir = "ILSVRC/val" path_map = {} for m in mappings: path_map[os.path.join(src_dir, m[0])] = os.path.join(target_dir, m[1], m[0]) # from https://www.kaggle.com/competitions/imagenet-object-localization-challenge/data with ZipFile('imagenet.zip', 'r') as zf: with ZipFile('imagenet-val.zip', 'w') as ozf: dirs = set() for path in zf.namelist(): if path.startswith("ILSVRC/Data/CLS-LOC/val/"): newpath = path_map[path] ozf.writestr(newpath, zf.read(path)) elif path == "ILSVRC/ImageSets/CLS-LOC/val.txt": ozf.writestr("ILSVRC/val.txt", zf.read(path))