face-classification icon indicating copy to clipboard operation
face-classification copied to clipboard

unable to load model

Open DLeeeeeee opened this issue 6 years ago • 2 comments

when I ran: python pred.py --img_dir test --model face_model.pkl

got error: Traceback (most recent call last): File "pred.py", line 103, in main() File "pred.py", line 81, in main clf, labels = pickle.load(f) TypeError: a bytes-like object is required, not 'str'

I tried pickle loading using other encoding option and also tried open file with "rb", but no good result.

Could you please tell me how to solve it? is it a version problem? OS: ubuntu 16.04 python: 3.5

DLeeeeeee avatar Oct 17 '18 01:10 DLeeeeeee

If you are using the python3 then use this code to read pickle file.

with open(model_path,'rb') as f: clf, labels = pickle.load(f,encoding='latin1')

Akashpanchal95 avatar Mar 31 '19 11:03 Akashpanchal95

Hi, this still doesn't work for me. Here is my error now:

in main(input_dir, output_dir, model_path) 49 # load the model 50 with open(model_path, 'rb') as f: ---> 51 clf, labels = pickle.load(f, encoding='latin1') 52 53 print("classifying images in {}".format(input_dir)) ModuleNotFoundError: No module named 'copy_reg\r'

OS: windows 10 python 3.6.8

halfendt avatar Sep 03 '19 22:09 halfendt