qubvel / segmentation_models.pytorch

Semantic segmentation models with 500+ pretrained convolutional and transformer-based backbones.
https://smp.readthedocs.io/
MIT License
9.1k stars 1.62k forks source link

More classes result in smaller model? #861

Closed fynv closed 1 month ago

fynv commented 3 months ago

I'm not familiar with the internal structure of the Unet model. However, I have one assumption, which I think is reasonable, that when I increase the number of output channels, the resulted model should be bigger because there are more trainable paramters.

I have a training dataset with 6 labels and both input and output are 640x480, 3 channels. Each set of labels are stored as 2 rgb images.

I first trained a model with 3 output channels: model = smp.Unet( encoder_name="se_resnext50_32x4d", encoder_weights= "imagenet", classes=3 ) The .pth file I get is 138,575,607 bytes.

Then I trained: model = smp.Unet( encoder_name="se_resnext50_32x4d", encoder_weights= "imagenet", classes=6 ) And the .pth file is 138,574,659 bytes, which is slightly smaller than the 3 channel model.

I don't understand why it is happening like this. (There's nothing strange of the behavior of the models.)

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 7 days with no activity.