facebookresearch / vissl

VISSL is FAIR's library of extensible, modular and scalable components for SOTA Self-Supervised Learning with images.
https://vissl.ai
MIT License
3.24k stars 330 forks source link

Can't load pretrained seer/swav checkpoints (RG_Y_128GF) #572

Closed JonathanBhimaniBurrows closed 1 year ago

JonathanBhimaniBurrows commented 1 year ago

Instructions To Reproduce the 🐛 Bug:

Title Issue when trying to load pretrained weights for Swav RegNet 128 GF

  1. what changes you made (git diff) or what code you wrote I followed the exact instructions here https://colab.research.google.com/github/facebookresearch/vissl/blob/v0.1.6/tutorials/Using_a_pretrained_model_for_inference_V0_1_6.ipynb#scrollTo=NCwpxr5lNBQy

only change was to the config itself, as follows cfg = [ 'config=home/jrbb/xxx/xxx/models/RegNet_128gf.yaml', 'config.MODEL.WEIGHTS_INIT.PARAMS_FILE=/home/jrbb/xxx/xxx/swav/swav_RGNT128_pretrain.torch', #renamed chkpt 'config.MODEL.FEATURE_EVAL_SETTINGS.EVAL_MODE_ON=True', 'config.MODEL.FEATURE_EVAL_SETTINGS.FREEZE_TRUNK_ONLY=True', 'config.MODEL.FEATURE_EVAL_SETTINGS.EXTRACT_TRUNK_FEATURES_ONLY=True', 'config.MODEL.FEATURE_EVAL_SETTINGS.SHOULD_FLATTEN_FEATS=False' ]

All installations worked without errors

  1. what exact command you run: cfg = compose_hydra_configuration(cfg)

  2. what you observed (including full logs):

  3. Exception has occurred: MissingConfigException Could not load config/home/jrbb/xxx/xxx/models/RegNet_128gf.yaml. Available options: resnet50_synthetic File "/home/jrbb/vissl/vissl/utils/hydra_config.py", line 125, in compose_hydra_configuration return compose("defaults", overrides=overrides) File "/home/jrbb/xxx/xxx/training/utils.py", line 800, in build_dataset cfg = compose_hydra_configuration(cfg)

  4. please simplify the steps as much as possible so they do not require additional resources to run, such as a private dataset.

Expected behavior:

If there are no obvious error in "what you observed" provided above, please tell us the expected behavior. No errors

Environment:

Provide your environment information using the following command:


sys.platform linux Python 3.9.12 (main, Jun 1 2022, 11:38:51) [GCC 7.5.0] numpy 1.19.5 Pillow 9.1.1 vissl 0.1.6 @/home/jrbb/vissl/vissl GPU available True GPU 0 Tesla V100-SXM2-16GB CUDA_HOME /usr/local/cuda torchvision 0.13.1+cu102 @/home/jrbb/.conda/envs/py39/lib/python3.9/site-packages/torchvision hydra 1.0.7 @/home/jrbb/.conda/envs/py39/lib/python3.9/site-packages/hydra classy_vision 0.7.0.dev @/home/jrbb/.conda/envs/py39/lib/python3.9/site-packages/classy_vision tensorboard 2.4.0 apex unknown cv2 4.5.5 PyTorch 1.12.1+cu102 @/home/jrbb/.conda/envs/py39/lib/python3.9/site-packages/torch PyTorch debug build False


PyTorch built with:

CPU info:


Architecture x86_64 CPU op-mode(s) 32-bit, 64-bit Byte Order Little Endian CPU(s) 8 On-line CPU(s) list 0-7 Thread(s) per core 2 Core(s) per socket 4 Socket(s) 1 NUMA node(s) 1 Vendor ID GenuineIntel CPU family 6 Model 79 Model name Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz Stepping 1 CPU MHz 2627.823 CPU max MHz 3000.0000 CPU min MHz 1200.0000 BogoMIPS 4600.13 Hypervisor vendor Xen Virtualization type full L1d cache 32K L1i cache 32K L2 cache 256K L3 cache 46080K NUMA node0 CPU(s) 0-7


ASIDE: is there a better way to load pretrained weights? Previously I tried using the torchvision model for regnet128 with the VISSL checkpoint provided, but so many of the keys differed by more than the prefix that it seemed futile to continue down that path

Thanks :)

JonathanBhimaniBurrows commented 1 year ago

Will update this and then close Seems like you need to reference the models in the vissl directly in the config - uploading your own to a different path does not work So this cfg = [ 'config=home/jrbb/xxx/xxx/models/RegNet_128gf.yaml' ] becomes this cfg = [ 'config=pretrain/swav/models/regnet128Gf.yaml' ] My mistake