bubbliiiing / mobilenet-yolov4-pytorch

这是一个mobilenet-yolov4的库,把yolov4主干网络修改成了mobilenet,修改了Panet的卷积组成,使参数量大幅度缩小。
MIT License
369 stars 104 forks source link

B导,我写改了一下ghostnet的网络模型,然后已经训练出来了。现在在循行get_map.py的时候发现有下面的问题 #45

Open WDQGO opened 1 year ago

WDQGO commented 1 year ago

class GhostNet(nn.Module): def init(self, pretrained=True): super(GhostNet, self).init() model = ghostnet() if pretrained: state_dict = torch.load("model_data/ghostnet_weights.pth") model.load_state_dict(state_dict) del model.global_pool del model.conv_head del model.act2 del model.classifier del model.blocks[9] self.model = model

def forward(self, x):
    x = self.model.conv_stem(x)
    x = self.model.bn1(x)
    x = self.model.act1(x)
    feature_maps = []

    for idx, block in enumerate(self.model.blocks):
        x = block(x)
        if idx in [2,4,6,8]:
            feature_maps.append(x)
    return feature_maps[1:]

需要加载 model_data/ghostnet_weights.pth,发现模型不匹配,我的ghostnet分类模型的特征提取网络是需要重新训练吗

bubbliiiing commented 1 year ago

为啥要加载他,我不理解