endernewton / tf-faster-rcnn

Tensorflow Faster RCNN for Object Detection
https://arxiv.org/pdf/1702.02138.pdf
MIT License
3.65k stars 1.57k forks source link

TypeError: load() got an unexpected keyword argument 'encoding' #294

Open TinusChen opened 6 years ago

TinusChen commented 6 years ago

Run trainning shell to train our own dataset: ./experiments/scripts/train_faster_rcnn.sh 0 pascal_voc vgg16 or ./experiments/scripts/train_faster_rcnn.sh 0 pascal_voc res101

Error log: File "/path/to/tf-faster-rcnn-master/tools/../lib/datasets/pascal_voc.py", line 105, in gt_roidb roidb = pickle.load(fid, encoding='bytes') TypeError: load() got an unexpected keyword argument 'encoding'

Code:

if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: try: roidb = pickle.load(fid) except: roidb = pickle.load(fid, encoding='bytes') print('{} gt roidb loaded from {}'.format(self.name, cache_file)) return roidb

Env: OS: Ubuntu 16.04 Python: anaconda python 2.7.12

TinusChen commented 6 years ago

I found a cache directory and fixed the problem like this: rm data/cache -r Maybe I've used python3 to train the model which led to a serialization compatibility issue.

pangyanhui923 commented 5 years ago

you can modify this file ./home/wangwenzhong/project/test/tf-faster-rcnn/lib/datasets/voc_eval.py.

if not os.path.isfile(cachefile):

# load annotations

recs = {} for i, imagename in enumerate(imagenames): recs[imagename] = parse_rec(annopath.format(imagename)) if i % 100 == 0: print('Reading annotation for {:d}/{:d}'.format( i + 1, len(imagenames)))

save

print('Saving cached annotations to {:s}'.format(cachefile)) with open(cachefile, 'w') as f: pickle.dump(recs, f)

else:

# load

with open(cachefile, 'rb') as f:

try:

recs = pickle.load(f)

except:

recs = pickle.load(f, encoding='bytes')

extract gt objects for this class

liuyang7710 commented 5 years ago

I also have this problem. Have you fixed it? how to do it?