qubvel-org / segmentation_models.pytorch

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

How to calculate the parameters and the Flops, showing the network structure? #610

Closed weasley817 closed 2 years ago

weasley817 commented 2 years ago

Hi! Thank you for providing such a useful tool I have a question about calculating the amount of parameters and the amount of calculation.I'm using the Unet model and ‘ENCODER ‘’is'timm-mobilenetv3_large_100'. The following error occurs when I use thop

“” [WARN] Cannot find rule for <class 'torch.nn.modules.linear.Identity'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'timm.models.efficientnet_blocks.DepthwiseSeparableConv'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.container.Sequential'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'timm.models.efficientnet_blocks.InvertedResidual'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.activation.Hardsigmoid'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'timm.models.efficientnet_blocks.SqueezeExcite'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'timm.models.efficientnet_blocks.ConvBnAct'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'timm.models.mobilenetv3.MobileNetV3Features'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.encoders.timm_mobilenetv3.MobileNetV3Encoder'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.base.modules.Conv2dReLU'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.base.modules.Attention'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.decoders.unet.decoder.DecoderBlock'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.container.ModuleList'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.decoders.unet.decoder.UnetDecoder'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'torch.nn.modules.activation.Sigmoid'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.base.modules.Activation'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.base.heads.SegmentationHead'>. Treat it as zero Macs and zero Params. [WARN] Cannot find rule for <class 'segmentation_models_pytorch.decoders.unet.model.Unet'>. Treat it as zero Macs and zero Params. “” flops is 2350751032.0 params is 6664057.0

I'm not sure if these warnings can be ignored.

I look forward to your reply in your free time!

github-actions[bot] commented 2 years 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 2 years ago

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