MMdnn icon indicating copy to clipboard operation
MMdnn copied to clipboard

Pytorch to IR conversion: 'Collections.OrderedDict'a object has no attribute

Open Hasan6979 opened this issue 5 years ago • 3 comments

Platform (like ubuntu 16.04/win10): Ubuntu 18.04

Python version: Python 3.6

Source framework with version : Pytorch 0.4.0

Pre-trained model path (webpath or webdisk path): https://download.pytorch.org/models/resnet101-5d3b4d8f.pth

I have gotten all the required versions and packages given in : https://github.com/microsoft/MMdnn/blob/master/requirements/linux-py3.txt

In the FAQ it says that its because I have a model which has just the weights. But I am using the pre-trained model so there shouldn't be such an issue right ?

Anything I might be missing ?

Hasan6979 avatar May 13 '20 16:05 Hasan6979

Hi @Hasan6979 , models downloaded directly from torchvision only have weights (you can check it easily with netron). An extra precedure of load and save is required, which we have implemented in mmdownload command. So try mmdownload -f pytorch -n resnet101 -o ./

XiaoXYe avatar May 16 '20 06:05 XiaoXYe

Hi @XiaoXYe The problem is with using mmdownload with me is that where I am working, they have blocked wget so mmdownload fails. What steps can I do to have the architecture with the weights ? The load and save step that you are talking about.

Hasan6979 avatar May 16 '20 07:05 Hasan6979

Hi @Hasan6979 , This code will help you

import torch  
import torchvision.models as models
net = models.resnet101(pretrained=False)
net.load_state_dict(torch.load('resnet101.pth'))
torch.save(net, 'imagenet_resnet101.pth')

XiaoXYe avatar May 16 '20 07:05 XiaoXYe