PSPNet-tensorflow icon indicating copy to clipboard operation
PSPNet-tensorflow copied to clipboard

How to generate ckpt pre-train model from caffemodel?

Open John1231983 opened this issue 7 years ago • 10 comments

Hello, I was successful to achieve the performance as your report. I was download the PSPNet caffe and build with cudnn 5.0.

Then I run the code

python convert.py ./pspnet101_cityscapes_713.prototxt --caffemodel ./pspnet101_cityscapes.caffemodel --data-output-path ./pspnet-init.ckpt

However, I got the error as bellow. Did you have same error when you generate the cpkt file? Thanks

caffe-tensorflow/kaffe/tensorflow/transformer.py", line 242, in load
    NodeKind.BatchNorm]),
AttributeError: type object 'NodeKind' has no attribute 'BatchNorm'

Note that, I also changed the layers.py as below because the original code used name as BatchNorm

'BN': shape_identity,
'Interp': shape_identity,

John1231983 avatar Dec 13 '17 04:12 John1231983

Hello John! I have the same problem with you. Do you solve the problem?

YanZhiyuan0918 avatar Dec 14 '17 01:12 YanZhiyuan0918

@John1231983

YanZhiyuan0918 avatar Dec 14 '17 02:12 YanZhiyuan0918

@YanZhiyuan0918: Please look at the solution at https://github.com/Vladkryvoruchko/PSPNet-Keras-tensorflow

Let me know if you have any problem

John1231983 avatar Dec 14 '17 05:12 John1231983

@John1231983 Thanks a lot for advice. When I try to directly use the .npy model provided by [(https://github.com/Vladkryvoruchko/PSPNet-Keras-tensorflow)] to convert to .ckpt model, I run the code: python npy2ckpt.py ./model/pspnet101_cityscapes.npy --save-dir=./model/

then I have the problem as follow: ValueError: Variable conv4_17_3x3_bn/mean does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

Do you know this problem?

YanZhiyuan0918 avatar Dec 14 '17 07:12 YanZhiyuan0918

OK. I see. I meet the problem and I need to used other code to convert npy2ckpt in the https://github.com/DrSleep/tensorflow-deeplab-resnet/tree/master/kaffe

John1231983 avatar Dec 14 '17 07:12 John1231983

Yes, I think so. The code npy2ckpt.py I used is also from https://github.com/DrSleep/tensorflow-deeplab-resnet . I think there is something unmatched in it .

YanZhiyuan0918 avatar Dec 14 '17 09:12 YanZhiyuan0918

@YanZhiyuan0918: have you solve the problem? Thanks

John1231983 avatar Dec 15 '17 13:12 John1231983

@John1231983 Not yet. Maybe we can ask for @hellochick for help.

YanZhiyuan0918 avatar Dec 18 '17 08:12 YanZhiyuan0918

Hey @John1231983 @YanZhiyuan0918 , I only transformed the weights, and handcraft the model. So I did not use the Caffe - Tensorflow code to generate model.py. Also, when you try to load the weights, you should care about the mismatching of variable name, such as gamma and scale in batch normalization layer.

hellochick avatar Dec 18 '17 09:12 hellochick

Hey@hellochick , when train from scratch on ade20k dataset, we first need to restore pre-trained model such as resnet-50?

shipengai avatar Feb 24 '18 06:02 shipengai