tf-faster-rcnn icon indicating copy to clipboard operation
tf-faster-rcnn copied to clipboard

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

Open TinusChen opened this issue 7 years ago • 3 comments

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 avatar Feb 05 '18 10:02 TinusChen

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.

TinusChen avatar Feb 05 '18 10:02 TinusChen

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

pangyanhui923 avatar Dec 27 '18 11:12 pangyanhui923

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

liuyang7710 avatar Aug 07 '19 12:08 liuyang7710