-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
I have an issue where I'm running this part:
`import segmentation_models_pytorch as smp
import torch
model = smp.from_pretrained(r'modelsaves\Teacher\mit_b3_Segformer')
out = model.encoder(torch.rand(1,2,512,512))
print([s.size() for s in out])`
In which I isolated the error, and I get this:
[torch.Size([1, 2, 512, 512]), torch.Size([1, 0, 256, 256]), torch.Size([1, 64, 128, 128]), torch.Size([1, 128, 64, 64]), torch.Size([1, 320, 32, 32]), torch.Size([1, 512, 16, 16])]
For some reason the 2nd Feature Map has 0 channels? How could this be? I have tried this with other encoders and model archs and I don't get this. Is there something I am missing?
=> Note, the model.safetensors is saved with an earlier version of SMP, I tried with 0.3.5 version, then updated to the latest and the issue persists.
I tried this:
model = smp.from_pretrained(r'modelsaves\Teacher\mit_b3_Segformer')
out = model.encoder(torch.rand(1,2,512,512))
print([s.size() for s in out])
model = smp.Segformer(encoder = 'mit_b3', in_channels = 2, classes = 3, encoder_weights = None)
# model = model.from_pretrained(r'modelsaves\Teacher\mit_b3_Segformer')
out = model.encoder(torch.rand(1,2,512,512))
print([s.size() for s in out])
Got this
[torch.Size([1, 2, 512, 512]), torch.Size([1, 0, 256, 256]), torch.Size([1, 64, 128, 128]), torch.Size([1, 128, 64, 64]), torch.Size([1, 320, 32, 32]), torch.Size([1, 512, 16, 16])]
[torch.Size([1, 2, 512, 512]), torch.Size([1, 64, 256, 256]), torch.Size([1, 64, 128, 128]), torch.Size([1, 128, 64, 64]), torch.Size([1, 256, 32, 32]), torch.Size([1, 512, 16, 16])]
So the issue is for sure in the saved model.safetensors .
I would like to understand how I can troubleshoot something like this