shicai / DenseNet-Caffe

DenseNet Caffe Models, converted from https://github.com/liuzhuang13/DenseNet
357 stars 273 forks source link

DenseNet161 deploy prototxt (ceil_mode and round_mode) error #37

Open mrgransky opened 4 years ago

mrgransky commented 4 years ago

Loading .caffemodel and deploy.ptototxt in caffe for TEST phase returns the following error:

[libprotobuf ERROR google/protobuf/text_format.cc:288] Error parsing text-format caffe.NetParameter: 54:14: Message type "caffe.PoolingParameter" has no field named "ceil_mode".
F0430 20:48:24.400027 24399 upgrade_proto.cpp:90] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: MODELS/DenseNet161/ImageNet/deploy.prototxt
*** Check failure stack trace: ***
Aborted (core dumped

ur Baidu link (https://pan.baidu.com/s/1gfjD8cF) seems to be broken too! Do u have updated version of that link?

LYC-vio commented 4 years ago

I've found that this problem (has no field named "ceil_mode") could be solved by changing the "ceil_mode: false" line to "round_mode: FLOOR" in the prototxt file to fit the new version of Caffe. The new version of Caffe use round_mode: CEIL/FLOOR to choose which mode to use (default CEIL).

I have tested this modification on Densenet161 and it didn't seem to affect the performance.

Hope this can help.

mrgransky commented 4 years ago

Tnx for the update, now I get the following error:

Cannot copy param 0 weights from layer 'conv1'; shape mismatch.  Source param shape is 96 3 7 7 (14112); target param shape is 64 3 7 7 (9408). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.
*** Check failure stack trace: ***
Aborted (core dumped)

It seems conv1 should be renamed to something cuz I found similar issue ppl solved this new problem here, but how do we fix it for DenseNet161?

Did u encounter the same problem?

LYC-vio commented 4 years ago

Sorry, I didn't encounter this problem. Maybe you can check whether your .caffemodel file matches the .prototxt file correctly... I mean, the conv1 layer of DenseNet_121 and DenseNet_169 is 64 3 7 while the conv1 layer of DenseNet_161 is 96 3 7, maybe you have mismatched DenseNet_169.caffemodel to DenseNet_161.prototxt or something like that I guess?

mrgransky commented 4 years ago

Oohh! yes, u're absolutely right! I had mistakenly had different weight.caffemodel and deploy.prototxt files! now it works flawless with modification u suggested: replace ceil_mode: false in deploy.prototxt to round_mode: FLOOR. Cheers,

LYC-vio commented 4 years ago

Congrats! Happy to hear that!

mrgransky commented 4 years ago

In another PC in which caffe-gpu is installed via anaconda, I get error for both ceil_mode: false and round_mode: FLOOR though!

deploy.prototxt with ceil_mode: false:

[libprotobuf ERROR google/protobuf/text_format.cc:307] Error parsing text-format caffe.NetParameter: 54:14: Message type "caffe.PoolingParameter" has no field named "ceil_mode".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0517 18:27:14.369987 16944 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: MODELS/DenseNet161/ImageNet/deploy.prototxt
*** Check failure stack trace: ***
Aborted

deploy.prototxt with round_mode: FLOOR:

[libprotobuf ERROR google/protobuf/text_format.cc:307] Error parsing text-format caffe.NetParameter: 54:15: Message type "caffe.PoolingParameter" has no field named "round_mode".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0517 18:32:19.467856 17462 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: MODELS/DenseNet161/ImageNet/deploy.prototxt
*** Check failure stack trace: ***
Aborted

This is my python specification and caffe version:

Python 2.7.17 |Anaconda, Inc.| (default, Oct 21 2019, 19:04:46) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>> caffe.__version__
'1.0.0'

I also noticed #32 is an open issue regarding this but is there any workaround for anaconda version of caffe?

LYC-vio commented 4 years ago

I don't have any idea about this error message... A possible solution is to check those corresponding lines mentioned by https://github.com/BVLC/caffe/pull/3057/files (see also #1) in caffe-gpu from anaconda to see what params are actually used and modify the .prototxt file.

LYC-vio commented 4 years ago

Alternatively, you can install another caffe from source code and use sys.path.insert to specify which caffe to use. eg:

import sys
sys.path.insert(0,"path/to/your/caffe/python")
import caffe
mrgransky commented 4 years ago

@LYC-vio I'm afraid installing caffe from source is an option cuz this a univ GPU clusters and we do not get sudo prriviledge for package installation/manipulation!