Caffe Python 3.6 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 5

223 views
Skip to first unread message

tirhum lamauny

unread,
Nov 15, 2017, 6:02:05 AM11/15/17
to Caffe Users

Hello
I use python 3.6 with anaconda 3
I am on CentOS 6, gcc 4.9

I have the following error :

File "make_predictions_1.py", line 51, in <module>
    mean_blob.ParseFromString(f.read())
  File "/work/irlin355_1/gratienj/BigData/local/anaconda3/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 5: ordinal not in range(128)

when in python script make_predictions_1.py, I try to read the "mean.binaryproto" that have been generate
by the "caffe/bin/compute_image_mean" c++ executable tools that compute the mean image of a collection of pictures.


Does any body have an idea.

I suppose that I have a problem in the python layer that have been generated while compiling caffe framework
In the python module caffe.proto.caffe_pb2, when we read the  mean.binaryproto file , there is a mismatch between
string in ascii or in UTF8 and the transformation in bytes.

I try to regenarate my protoc binary in case it was generated with the wrong python version...

I do not known which error I have done in my caffe framework generation.

I thing that my C++ layer works as the training phase seems OK.
I think I have a problem of compatibility between my C++ layer that generate the mean.binaryproto file
and the python layer that try to read and parse this file.

Thank you for any help or sugestion to check

TiRhum

tirhum lamauny

unread,
Nov 18, 2017, 4:02:26 PM11/18/17
to Caffe Users
I have found the problem :
With python 3.6, you have to specify 'rb' when you open a file the syntax to read a protobuf file is :

mean_blob = caffe_pb2.BlobProto()
with open('mean.binaryproto','rb') as f :
     mean_blob.ParseFromString(f.read())
Reply all
Reply to author
Forward
0 new messages