polarisZhao / PFLD-pytorch

PFLD pytorch Implementation
808 stars 198 forks source link

Number of parameters of PFLD #22

Open in-die-nibelungen opened 4 years ago

in-die-nibelungen commented 4 years ago

The paper says that PFLD 1X and PFLD 0.25X has 12.5 Mb and 2.1 Mb, respectively. As far as I confirmed with thop.profile and torchsummary.summary, the number of parameters of PFLD 1X's seems 1.26M, about ten times smaller than 12.5Mb.

What's `12.5Mb' meaning?

I confirmed it with the following code:

import numpy as np
import torch
from torchvision.models import MobileNetV2
from thop import profile
from torchsummary import summary

from models.pfld import PFLDInference

# models.
# MobileNetV2's are the references.
pfld_backbone=PFLDInference()
mobilenetv2 = MobileNetV2()
mobilenetv2_025 = MobileNetV2(width_mult=0.25)

# dummy input.
inputs = torch.randn([1,3,112,112])

names = ['PFLD', 'MobileNetV2', 'MobileNetV2_wm-0.25']
nets = [pfld_backbone, mobilenetv2, mobilenetv2_025]

# to Mega.
denom = np.array((1e+6,)*2)

# profiling.
for name, net in zip(names, nets):
    rlt=profile(net, inputs=(inputs,))
    print('{0}: {1[1]:.2f}M'.format(name, np.array(rlt)/denom))

#for name, net in zip(names, nets):
#    print(name)
#    summary(net, (3,112, 112))

Thanks in advance

axhionning commented 2 years ago

The paper says that PFLD 1X and PFLD 0.25X has 12.5 Mb and 2.1 Mb, respectively. As far as I confirmed with thop.profile and torchsummary.summary, the number of parameters of PFLD 1X's seems 1.26M, about ten times smaller than 12.5Mb.

What's `12.5Mb' meaning?

I confirmed it with the following code:

import numpy as np
import torch
from torchvision.models import MobileNetV2
from thop import profile
from torchsummary import summary

from models.pfld import PFLDInference

# models.
# MobileNetV2's are the references.
pfld_backbone=PFLDInference()
mobilenetv2 = MobileNetV2()
mobilenetv2_025 = MobileNetV2(width_mult=0.25)

# dummy input.
inputs = torch.randn([1,3,112,112])

names = ['PFLD', 'MobileNetV2', 'MobileNetV2_wm-0.25']
nets = [pfld_backbone, mobilenetv2, mobilenetv2_025]

# to Mega.
denom = np.array((1e+6,)*2)

# profiling.
for name, net in zip(names, nets):
    rlt=profile(net, inputs=(inputs,))
    print('{0}: {1[1]:.2f}M'.format(name, np.array(rlt)/denom))

#for name, net in zip(names, nets):
#    print(name)
#    summary(net, (3,112, 112))

Thanks in advance

I have the same question as you,have you figure out this? Could you please tell me why?