0

I want to import Resnet50 pretrain file "ResNet-50-model.caffemodel" to chainer. Here is chainer code:

class chexnet(L.ResNet50Layers):

def __init__(self, pretrained_model="auto", out_features=2):
    super(chexnet, self).__init__(pretrained_model)
    with self.init_scope():
        self.classifier = L.Linear(2048, out_features)

But i got the error message as below :

  File "/home/tamnt27/.local/lib/python3.5/site-packages/chainer/links/model/vision/resnet.py", line 148, in convert_caffemodel_to_npz
    caffemodel = CaffeFunction(path_caffemodel)
  File "/home/tamnt27/.local/lib/python3.5/site-packages/chainer/links/caffe/caffe_function.py", line 151, in __init__
    net.MergeFromString(model_file.read())
google.protobuf.message.DecodeError: Error parsing message

I don't know why this error happens, it should work, please help me. Thank you all.

  • Just a quick question, does the same error occur when you only instantiate `ResNet50Layers` itself rather than subclass, by `model = ResNet50Layers()`?? – corochann Jul 17 '18 at 22:53
  • @corochann, I didn't try that. However, it works OK on Windows environment. The error happened on Ubuntu 16.4, Python 2.7. Now i can use .npz format instead of caffemodel format. – Tâm Nguyễn Jul 18 '18 at 03:27
  • Did you send caffemodel file from windows to ubuntu? is there a possibility that you sent file with windows line ending to linux machine? – corochann Jul 18 '18 at 04:25
  • Anyway, good to know that you can at least work on with npz model format. – corochann Jul 18 '18 at 04:25

1 Answers1

1

I tried to reproduce your situation, but could not.

My environment is

  • python2.7
  • chainer4.2.0
  • cupy4.2.0

I downloaded a model from https://onedrive.live.com/?authkey=%21AAFW2-FVoxeVRck&id=4006CBB8476FF777%2117887&cid=4006CBB8476FF777

and placed it on ~/.chainer/dataset/pfnet/chainer/models/ResNet-50-model.caffemodel

I think the downloaded file is corrupted, therefore I recommend you to check md5sum by

$ md5sum ~/.chainer/dataset/pfnet/chainer/models/ResNet-50-model.caffemodel
44b20660c5948391734036963e855dd2

If the md5sum is different from mine, try download the model again.

Yuki Hashimoto
  • 1,013
  • 7
  • 19