i trained the best model on this repo GitHub - gastruc/osv5m now i am trying to test the model after saving it and i am getting a size mismatch error
This is the error
This is the error
/usr/local/lib/python3.10/dist-packages/torch/nn/init.py:511: UserWarning: Initializing zero-element tensors is a no-op
warnings.warn(“Initializing zero-element tensors is a no-op”)
/content/osv5m-main/models/losses.py:54: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don’t have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
self.matrixes = torch.load(join(data_path, “quadtree_matrixes.pt”))
/content/osv5m-main/models/losses.py:55: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See .md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don’t have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
self.dicts = torch.load(join(data_path, “quadtree_dicts.pt”))
/content/osv5m-main/models/losses.py:56: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See .md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don’t have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
self.id_to_quad = torch.load(join(data_path, “id_to_quad_10_1000.pt”))
Error executing job with overrides: [‘+pt_model_path=${hydra:runtime.config_sources}’]
Traceback (most recent call last):
File “/content/osv5m-main/test.py”, line 78, in main
) = hydra_boilerplate(cfg)
File “/content/osv5m-main/test.py”, line 36, in hydra_boilerplate
trainer, model = load_model(cfg, dict_config, cfg.wandb_id)
File “/content/osv5m-main/test.py”, line 29, in load_model
model = Geolocalizer.load_from_checkpoint(cfg.checkpoint, cfg=cfg.model)
File “/usr/local/lib/python3.10/dist-packages/pytorch_lightning/utilities/model_helpers.py”, line 125, in wrapper
return self.method(cls, *args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/pytorch_lightning/core/module.py”, line 1582, in load_from_checkpoint
loaded = _load_from_checkpoint(
File “/usr/local/lib/python3.10/dist-packages/pytorch_lightning/core/saving.py”, line 91, in _load_from_checkpoint
model = _load_state(cls, checkpoint, strict=strict, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/pytorch_lightning/core/saving.py”, line 187, in _load_state
keys = obj.load_state_dict(checkpoint[“state_dict”], strict=strict)
File “/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py”, line 2584, in load_state_dict
raise RuntimeError(
RuntimeError: Error(s) in loading state_dict for Geolocalizer:
size mismatch for model.mid.classif.7.weight: copying a param with shape torch.Size([1, 512]) from checkpoint, the shape in current model is torch.Size([0, 512]).
size mismatch for model.mid.classif.7.bias: copying a param with shape torch.Size([1]) from checkpoint, the shape in current model is torch.Size([0]).
size mismatch for model.mid.reg.7.weight: copying a param with shape torch.Size([2, 512]) from checkpoint, the shape in current model is torch.Size([0, 512]).
size mismatch for model.mid.reg.7.bias: copying a param with shape torch.Size([2]) from checkpoint, the shape in current model is torch.Size([0]).
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.