models icon indicating copy to clipboard operation
models copied to clipboard

Load pretrain checkpoint in tf2 version

Open weichen456 opened this issue 6 years ago • 8 comments

Please provide the entire URL of the model you are using?

Describe the feature you request and the current behavior/state. Hello, I have noticed that in official detection model the checkpoint_utils.py show me how to load tf1 backone checkpoint to retinanet but I want to know how I can load tf2 restnet backbone to retinanet which doesn't save with name scope. I will very appreciation if I get you help. Thank you very much! Are you willing to contribute it (Yes/No)? No Any other info.

weichen456 avatar Apr 25 '20 02:04 weichen456

Thank you! Assigned to owners. This is a long-lasting issue. I hope the team can get to work on it.

saberkun avatar Apr 25 '20 03:04 saberkun

In general, you can comment out the checkpoint_utils call. tf.train.Checkpoint or keras.Model.load_weights can restore you TF2 checkpoints. I am just curious where do you obtain TF2 resnet backbone checkpoint. Is it of the image_classification project?

saberkun avatar Apr 25 '20 03:04 saberkun

In general, you can comment out the checkpoint_utils call. tf.train.Checkpoint or keras.Model.load_weights can restore you TF2 checkpoints. I am just curious where do you obtain TF2 resnet backbone checkpoint. Is it of the image_classification project?

Yes, I just replace the resnet arthitecture with image_classification prroject, but I can't load the pretrain checkpoint because the tf2 checkpoint don't save with scope name, the tf2 checkpoint variables like this , ( model/layer_with_weights-0/kernel/.ATTRIBUTES/VARIABLE_VALUE', [3, 3, 3, 32]), ('model/layer_with_weights-0/kernel/.OPTIMIZER_SLOT/optimizer/momentum/.ATTRIBUTES/VARIABLE_VALUE', [3, 3, 3, 32]), ('model/layer_with_weights-0/kernel/.OPTIMIZER_SLOT/optimizer/rms/.ATTRIBUTES/VARIABLE_VALUE', [3, 3, 3, 32]), ('model/layer_with_weights-1/beta/.ATTRIBUTES/VARIABLE_VALUE', [32]), ('model/layer_with_weights-1/beta/.OPTIMIZER_SLOT/optimizer/momentum/.ATTRIBUTES/VARIABLE_VALUE', [32]), ('model/layer_with_weights-1/beta/.OPTIMIZER_SLOT/optimizer/rms/.ATTRIBUTES/VARIABLE_VALUE', [32]), ('model/layer_with_weights-1/gamma/.ATTRIBUTES/VARIABLE_VALUE', [32]), ('model/layer_with_weights-1/gamma/.OPTIMIZER_SLOT/optimizer/momentum/.ATTRIBUTES/VARIABLE_VALUE', [32]), ('model/layer_with_weights-1/gamma/.OPTIMIZER_SLOT/optimizer/rms/.ATTRIBUTES/VARIABLE_VALUE', [32]) ...... so I am confused about which layers will be load. Can you give me a official example? Thank you very much!

weichen456 avatar Apr 25 '20 04:04 weichen456

Hi @weichen456, the backbone resnet implementation does not match image classification resnet model, due to legacy issue. I will assign the issue to the internal team.

saberkun avatar Apr 27 '20 05:04 saberkun

We are working on it with the compatible ResNet implementation.

pengchongjin avatar May 08 '20 22:05 pengchongjin

Hi @weichen456,

Now all Pretrain checkpoints can be loaded in tf2 version and you can find the list of pretrain checkpoints to be loaded in tf2 version.Thanks

laxmareddyp avatar Jan 25 '23 22:01 laxmareddyp

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Feb 02 '23 18:02 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Feb 09 '23 18:02 google-ml-butler[bot]