deep_learning_for_camera_trap_images icon indicating copy to clipboard operation
deep_learning_for_camera_trap_images copied to clipboard

Converting model to Pytorch

Open gullalc opened this issue 7 years ago • 8 comments

Hi @arashno ,

I need to convert your res152 recognition model to pytorch. I am using mmdnn for conversion, but I cannot find the output node which needs to be given to the mmdnn conversion command. I have visualized the graph using the meta file, and there is no name that looks like output, softmax or predictions.

Can you or anyone else help with the conversion?

gullalc avatar Aug 30 '18 09:08 gullalc

Hi, For the recognition only model, the output node of the ResNet-152 model is the fully connected layer at resnet.py line 53. I think the name of the output node should be: 'output:0'. For the model with identifying, counting, and additional attributes outputs, the name of the species recognition output node should be 'output0:0' Best, Arash

arashno avatar Aug 30 '18 18:08 arashno

I have tried output:0 with the following command: mmconvert -sf tensorflow -in snapshot-55.meta -iw snapshot-55 --dstNode output:0 -df pytorch -om serengeti_resnet_152.pth

but it gives me the error that node is not in the graph. AssertionError: output:0 is not in graph

gullalc avatar Aug 30 '18 19:08 gullalc

Actually, I am going to release a new version of this repo with new features in a few days. I will check convertibility to PyTorch for the new version. Please wait until I release the new version. Thanks, Arash

arashno avatar Aug 30 '18 22:08 arashno

Unfortunately, I was unable to convert the Tensorflow models to PyTorch. But, the good news is that I will release a PyTorch version in 1-2 weeks. I finished the coding and now I am doing testing and preparing the trained models now. Arash

arashno avatar Nov 08 '18 07:11 arashno

Just wondering what became of this?

r-barnes avatar Sep 30 '20 22:09 r-barnes

@arashno : Did you ever release a PyTorch version?

r-barnes avatar Jan 16 '22 04:01 r-barnes

@gullalc : It appears that valid node names for mmconvert include

 'output0/weights/Initializer/truncated_normal/shape'
 'output0/weights/Initializer/truncated_normal/mean'
 'output0/weights/Initializer/truncated_normal/stddev'
 'output0/weights/Initializer/truncated_normal/TruncatedNormal'
 'output0/weights/Initializer/truncated_normal/mul'
 'output0/weights/Initializer/truncated_normal'
 'output0/weights'
 'output0/weights/Assign'
 'output0/weights/read'
 'output0/weights/Regularizer/l2_regularizer/L2Loss'
 'output0/weights/Regularizer/l2_regularizer'
 'output0/biases/Initializer/Const'
 'output0/biases'
 'output0/biases/Assign'
 'output0/biases/read'
 'output0/weights/Momentum/Initializer/Const'
 'output0/weights/Momentum'
 'output0/weights/Momentum/Assign'
 'output0/weights/Momentum/read'
 'output0/biases/Momentum/Initializer/Const'
 'output0/biases/Momentum'
 'output0/biases/Momentum/Assign'
 'output0/biases/Momentum/read'

r-barnes avatar Jan 16 '22 04:01 r-barnes

Hi, Yes, the PyTorch version is available at https://github.com/arashno/pytorch_multigpu_csv But, unfortunately, I didn't have enough computational resources to train a full model. If you have access to enough computational power, I am up to improving the PyTorch repository.

arashno avatar Jan 16 '22 20:01 arashno