longcw / pytorch2caffe

Convert PyTorch model to Caffemodel
541 stars 151 forks source link

pytorch2caffe doesn't work for the last two layyers's convertion #28

Closed dzyjjpy closed 5 years ago

dzyjjpy commented 5 years ago

Hi @longcw , thanks for your extraordinary work for the tool: pytorch2caffe at first.

And I used it to convert svhn\ hopenet and other pytorch model successfully. However, when converting HeadPose, one of my own network for predicting roll,pitch, yaw degree of human face, the last two layers(220: scale+bn, 221:relu,), it didn't write the weights into .caffemodel like .prototxt describes. cannot get blobs data using: net.blobs[output_name].data after net.forward() As I debug the python code for using caffemodel, it shows no layer 220 and 221 in headpose net created by .prototxt and .caffemodel we got by convertion. Do you have any advice? Thanks

trohit920 commented 5 years ago

@dzyjjpy Hello, i am also trying to convert a Head Pose Estimation (Hopenet) model trained using pytorch to caffe by this repository. Can you share some advice how to use this repository to do so ?

longcw commented 5 years ago

@dzyjjpy @trohit920 Thanks for interested in this repo and I am very glad this is helpful for you. What's the type of your last two layers? Or you can provide me a simple model for debugging. I will try to find the reason when I have free time.

trohit920 commented 5 years ago

@longcw I am working on converting Hopenet model Link to caffe. You can check model file and download the model from this link model. Plese take a look. Thanks in advance.

dzyjjpy commented 5 years ago

@longcw Hi , I have convert successfully before. thanks for your concern

dzyjjpy commented 5 years ago

@trohit920 after network initialization, call the pytorch2caffe function to convert. pay attention to the output layers, as it has three branch, so you need to edit some code in pytorch2caffe.py