MMdnn
MMdnn copied to clipboard
Places365 Caffe to pytorch. Error when using the generated files
Platform (like ubuntu 16.04/win10): Ubuntu 16
Python version: 2.7
Source framework with version (like Tensorflow 1.4.1 with GPU): Caffe
Destination framework with version (like CNTK 2.3 with GPU): Pytorch 0.4.1
Pre-trained model path (webpath or webdisk path): https://github.com/CSAILVision/places365 In specific I am trying to convert VGG16-hybrid1365 and ResNet152-hybrid1365
Running scripts: mmconvert --srcFramework caffe --inputWeight vgg16_hybrid1365.caffemodel --inputNetwork deploy_vgg16_hybrid1365.prototxt --dstFramework pytorch -om vgg16places.pth
Hi,
As I described above, I am trying to convert places caffe pre-trained models to pytorch. The convertion procedure finish without error, but, When I want to use it I have troubles. These files are generated:
-
vgg16places.pth
-
vgg16places.py
The code that I am using in order to use the converted files is :
import vgg16places as vgg a = vgg.KitModel('vgg16places.pth')
Traceback (most recent call last): File "
", line 1, in File "vgg16places.py", line 26, in init __weights_dict = load_weights(weight_file) File "vgg16places.py", line 16, in load_weights weights_dict = np.load(weight_file, encoding='bytes').item() AttributeError: 'long' object has no attribute 'item'
Am I doing something wrong? I would appreciate if someone can give me a clue in order to solve this issue.
Hi @dhorka , please refer to How to load the converted PyTorch model. Thanks!
Hi @rainLiuplus, thanks , this solved my issue! Sorry for have not read it before. I did not found this document :( I would like to ask another doubt. The idea of convert this model to pytorch is because I would like to retrain the model. Is there any issue or something that I need to take into account to re-train a model converted by mmdnn?
Hi @dhorka, the converted model file .py
only contains the definition of network architecture and the .npy
file is the weights. So for re-training the model, in addition to loading the model, you also need to write some training codes to train the model. Thanks!