xiaolai-sqlai / mobilenetv3 Goto Github PK
View Code? Open in Web Editor NEWmobilenetv3 with pytorch,provide pre-train model
License: MIT License
mobilenetv3 with pytorch,provide pre-train model
License: MIT License
mobilev3 large那里是不是少了一个池化层
Hi Xiaolai,
I found it is hard to reduplicate the stated results. Could you please upload the train file also? The tricks in the learning rate setting and augmentation maybe the point for reproducing.
Thanks and it would be a wonderful work if the results can be reproduced.
Get 65.07% using the new small model, it's much lower than your claim.
Use these pretreatments.
transform_test = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
作者您好,
请问可以分享一下模型的训练参数和配置文件吗?谢谢
To be honest I think the previous 75+ acc was a misreport because his previous version has the attention part with much more params.
我想知道,在Se模块中,AdaptiveAvgPool2d(1)使用来做啥的呢?
I downloaded the small model and tested it, but only got accuracy 64.926%. Not sure is it because of preprocessing difference? Here is what I used:
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
val_loader = torch.utils.data.DataLoader(
datasets.ImageFolder(valdir, transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
normalize,
])),
batch_size=128, shuffle=False,
num_workers=1, pin_memory=True)
As title, ur code only do the shortcut when stride is 1.
And if the stride is 2, it doesnt add anything.
I wonder if the stride is right, for the stride of 13th bneck is 2 in the paper, however it's 1 in yours and the 14th bneck's is 2.
When inference on single image (batch size = 1) got error:
mobilenetv3.py", line 199, in forward
out = self.hs3(self.bn3(self.linear3(out)))
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 489, in __call__
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/batchnorm.py", line 76, in forward
exponential_average_factor, self.eps)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 1619, in batch_norm
raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 1280])
SE unit should be before the last convolution in the block ! ! !
Please see Figure 4 of Searching for MobilenetV3.
Hi, Beautiful code.
In Searching for MobileNetV3, the operator of the last two layers of Mobilenet_V3_Large are conv and NBN(No Batch Normlization), but self.bn3 appears on your code mobilenetv3/mobilenetv3.py line 130 and 187.
Please check your code.Thank you!
你好,在SeModule中插入的的BatchNorm2d模块是不是错了, 因为在AdaptiveAvgPool2d后特征图大小变为1x1,对这种特征图进行BN的话会报错。我的操作系统是Ubuntu18.04,torch==1.11.0+cu113; torchvision==0.12.0+cu113; CUDA:11.3
As with #5, the validation accuracy for the large model is also well below the stated. I was curious because the stated result, beating the official, with 1.4m less parameters would be impressive.
I only get: Prec@1 70.788 (29.212) Prec@5 89.410 (10.590)
Several things to fix in the model:
hi , my training loss is normal, but the validate loss is nan , Have you met anybody?
大佬, 你的这个InvterMobileBlock, 不应该是先SElayer,然后在进行point covn操作嘛?
Your SEModule is different from what the paper claimed. You can change it refer to https://github.com/moskomule/senet.pytorch/blob/master/senet/se_module.py
or my impementation https://github.com/kuan-wang/pytorch-mobilenet-v3/blob/master/mobilenetv3.py.
hello, may I ask, is the large model still in training? Do you still have the plan to upload?
Thank you!
NBN denotes no batch normalization.
In the original paper. In table 1. The author use conv2d 1x1, NBN in the 1x1x960 to 1x1x1280, which means they don't use batch norm in fc layers, but your code use bn. This is not the same as the original version of the paper. Although this little change may not influence the final results.
out = self.hs3(self.bn3(self.linear3(out)))
out = self.linear4(out)
model = torch.load(‘mbv3_small.pth.tar‘, map_location='cpu')
print('Loading base network...')
weight = model["state_dict"]
base_net = torch.nn.DataParallel(base_net)
base_net.load_state_dict(weights)
The program has been running, no response
Hello, do you still have the plan to release the pretrained model of mobilenetv3_large?
It seems that the AdaptiveAvgPool2d in SeModule not used in compute graph in your implementation.
请问您的MobileNetV3的性能比原论文的提升了不少,请问能给出这个模型的改进过程或者是您训练这个MobileNetV3的策略方法吗
tar -xvf mbv3_large.pth.tar
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
I found some details that differ from the original paper ,like squeeze and excite moduel,using BN in the final two layers. So could you list all of your details that are different from the original paper in README, pls? After that, I can figure out changes which are your own details and which are mistakes.
You should use the avg_pool to the input x, and use fc-->fc and expand as the input x's dimension. Then use the shortcut connection.
In the original Squeeze-and-Excitation Networks, the author found through experiments that when reduction = 16, precision and complexity are well balanced, and in your module, reduction is set to the current number of bneck output channels , what is the reason for this setting? Did it come from the experiment?
is the mbv3_small.pth.tar up to date? could I use it to load the model?
The paper has been updated. The last but one 'bneck' is updated in 'Table 1'. The 'exp size' is no longer 672 but 960. Please check it out.
Is it possible to provide a new pre-trained model based on the updated network structure?
Hi, thanks for your project.
I have a question: what's your image preprocessing method before inference? Do you subtract the mean and divide the standard value or other method? I want to use your trained model to finetune other classification task.
Thanks for your work!
In mobilenetv3 paper 6.1.1 Training setup, the dropout rate is 0.8. Do you use dropout in the code?
In code
def __init__(self, kernel_size, in_size, expand_size, out_size, nolinear, semodule, stride):
super(Block, self).__init__()
self.stride = stride
self.se = semodule
self.conv1 = nn.Conv2d(in_size, expand_size, kernel_size=1, stride=1, padding=0, bias=False)
self.bn1 = nn.BatchNorm2d(expand_size)
self.nolinear1 = nolinear
self.conv2 = nn.Conv2d(expand_size, expand_size, kernel_size=kernel_size, stride=stride, padding=kernel_size//2, groups=expand_size, bias=False)
self.bn2 = nn.BatchNorm2d(expand_size)
self.nolinear2 = nolinear
self.conv3 = nn.Conv2d(expand_size, out_size, kernel_size=1, stride=1, padding=0, bias=False)
self.bn3 = nn.BatchNorm2d(out_size)
self.shortcut = nn.Sequential()
if stride == 1 and in_size != out_size:
self.shortcut = nn.Sequential(
nn.Conv2d(in_size, out_size, kernel_size=1, stride=1, padding=0, bias=False),
nn.BatchNorm2d(out_size),
)
def forward(self, x):
out = self.nolinear1(self.bn1(self.conv1(x)))
out = self.nolinear2(self.bn2(self.conv2(out)))
out = self.bn3(self.conv3(out))
if self.se != None:
out = self.se(out)
out = out + self.shortcut(x) if self.stride==1 else out
return out
Due to the cat operation of residual network , I think "if stride == 1 and in_size != out_size:" should be changed to "if stride == 1 and in_size == out_size:"
Besides, "out = out + self.shortcut(x) if self.stride==1 else out" here I also think you may use residual network incorrectly
Thanks for sharing! Could you please tell me how to train the model by using my own dataset for classification?
Do you have any plans to supplement the code of the training section?
waiting for your reply
Line 28 in 5ec8ae3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.