# When i load GeosSeg model i see this error?

**URL:** <https://discuss.pytorch.org/t/when-i-load-geosseg-model-i-see-this-error/205850>\
**Category:** Uncategorized\
**Created:** [July 6, 2024, 12:09pm UTC](https://discuss.pytorch.org/t/when-i-load-geosseg-model-i-see-this-error/205850 "2024-07-06T12:09:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatemeh\_yousefi](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/fatemeh_yousefi/32/71239_2.png) [@fatemeh\_yousefi](https://discuss.pytorch.org/u/fatemeh_yousefi)\
**Post date:** [July 6, 2024, 12:09pm UTC](https://discuss.pytorch.org/t/when-i-load-geosseg-model-i-see-this-error/205850/1 "2024-07-06T12:09:36Z")

</div>

i follow the structure bellow in this github page :  
[WangLibo1995/GeoSeg: UNetFormer: A UNet-like transformer for efficient semantic segmentation of remote sensing urban scene imagery, ISPRS. Also, including other vision transformers and CNNs for satellite, aerial image and UAV image segmentation. (github.com)](https://github.com/WangLibo1995/GeoSeg)  
and train the data and when i want to test the model and see the result with this code: python GeoSeg/loveda\_test.py -c GeoSeg/config/loveda/dcswin.py -o fig\_results/loveda/dcswin\_test -t ‘d4’  
i got this error: ( i have to note that i didnt change any parameter just i changed the batch size to 1 becuase i got cuda out of memory error )  
model = Supervision\_Train.load\_from\_checkpoint(os.path.join(config.weights\_path, config.test\_weights\_name+‘.ckpt’), config=config)  
model.cuda()  
model.eval() model = Supervision\_Train.load\_from\_checkpoint(os.path.join(config.weights\_path, config.test\_weights\_name+‘.ckpt’), config=config)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/utilities/model\_helpers.py”, line 125, in wrapper  
return self.method(cls, \*args, \*\*kwargs)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/core/module.py”, line 1586, in load\_from\_checkpoint  
loaded = \_load\_from\_checkpoint(  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/core/saving.py”, line 63, in \_load\_from\_checkpoint  
checkpoint = pl\_load(checkpoint\_path, map\_location=map\_location)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/lightning\_fabric/utilities/cloud\_io.py”, line 56, in \_load  
with fs.open(path\_or\_url, “rb”) as f:  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/fsspec/spec.py”, line 1293, in open  
f = self.\_open(  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/fsspec/implementations/local.py”, line 184, in \_open  
return LocalFileOpener(path, mode, fs=self, \*\*kwargs)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/fsspec/implementations/local.py”, line 306, in **init**  
self.\_open()  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/fsspec/implementations/local.py”, line 311, in \_open  
self.f = open(self.path, mode=self.mode)  
FileNotFoundError: [Errno 2] No such file or directory: ‘/media/deed/Programs/Miss\_Yousefi/treesegmentation/model\_weights/loveda/dcswin-small-512crop-ms-epoch30/dcswin-small-512crop-ms-epoch30.ckpt’  
(airs) deed@deedasia-980GTX:/media/deed/Programs/Miss\_Yousefi/treesegmentation$ python GeoSeg/loveda\_test.py -c GeoSeg/config/loveda/dcswin.py -o fig\_results/loveda/dcswin\_test -t ‘d4’  
INFO:albumentations.check\_version:A new version of Albumentations is available: 1.4.11 (you have 1.4.10). Upgrade using: pip install --upgrade albumentations  
/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at …/aten/src/ATen/native/TensorShape.cpp:3587.)  
return \_VF.meshgrid(tensors, \*\*kwargs) # type: ignore[attr-defined]  
Traceback (most recent call last):  
File “GeoSeg/loveda\_test.py”, line 138, in   
main()  
File “GeoSeg/loveda\_test.py”, line 60, in main  
model = Supervision\_Train.load\_from\_checkpoint(os.path.join(config.weights\_path, config.test\_weights\_name+‘.ckpt’), config=config)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/utilities/model\_helpers.py”, line 125, in wrapper  
return self.method(cls, \*args, \*\*kwargs)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/core/module.py”, line 1586, in load\_from\_checkpoint  
loaded = \_load\_from\_checkpoint(  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/core/saving.py”, line 91, in \_load\_from\_checkpoint  
model = \_load\_state(cls, checkpoint, strict=strict, \*\*kwargs)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/pytorch\_lightning/core/saving.py”, line 187, in \_load\_state  
keys = obj.load\_state\_dict(checkpoint[“state\_dict”], strict=strict)  
File “/home/deed/anaconda3/envs/airs/lib/python3.8/site-packages/torch/nn/modules/module.py”, line 2189, in load\_state\_dict  
raise RuntimeError(‘Error(s) in loading state\_dict for {}:\n\t{}’.format(  
RuntimeError: Error(s) in loading state\_dict for Supervision\_Train:  
size mismatch for net.decoder.segmentation\_head.0.0.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([96, 96, 3, 3]).  
size mismatch for net.decoder.segmentation\_head.0.1.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([96]).  
size mismatch for net.decoder.segmentation\_head.0.1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([96]).  
size mismatch for net.decoder.segmentation\_head.0.1.running\_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([96]).  
size mismatch for net.decoder.segmentation\_head.0.1.running\_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([96]).  
can anyone help me to solve it ?

---

<div class="post-metadata">

**Author:** ![anantguptadbl](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/anantguptadbl/32/17784_2.png) [@anantguptadbl](https://discuss.pytorch.org/u/anantguptadbl)\
**Post date:** [July 7, 2024, 5:25am UTC](https://discuss.pytorch.org/t/when-i-load-geosseg-model-i-see-this-error/205850/2 "2024-07-07T05:25:51Z")

</div>

There seems to be a difference between the Model Structure that you have instantiated and the model structure whose weights you are retrieving from the checkpoint
