I encountered the following error when I was trying to run python train.py in repo tensorlayer/srgan.
Traceback (most recent call last):
File "train.py", line 357, in <module>
train()
File "train.py", line 75, in train
VGG = tl.models.vgg19(pretrained=True, end_with='pool4', mode='static')
File "/home/s1895566/venv/lib/python3.6/site-packages/tensorlayer/models/vgg.py", line 317, in vgg19
restore_model(model, layer_type='vgg19')
File "/home/s1895566/venv/lib/python3.6/site-packages/tensorlayer/models/vgg.py", line 169, in restore_model
npz = np.load(os.path.join('models', model_saved_name[layer_type]), encoding='latin1').item()
File "/home/s1895566/venv/lib/python3.6/site-packages/numpy/lib/npyio.py", line 447, in load
pickle_kwargs=pickle_kwargs)
File "/home/s1895566/venv/lib/python3.6/site-packages/numpy/lib/format.py", line 696, in read_array
raise ValueError("Object arrays cannot be loaded when "
ValueError: Object arrays cannot be loaded when allow_pickle=False
I did a little digging, and it turns out that recent development in numpy stated in numpy/numpy#13359 changed the default value of allow_pickle from True to False. A quick grep in tensorlayer folder suggested that most np.load() did not explicitly pass True argument for allow_pickle.
./models/vgg.py: npz = np.load(os.path.join('models', model_saved_name[layer_type]))
./models/vgg.py: npz = np.load(os.path.join('models', model_saved_name[layer_type]), encoding='latin1').item()
./files/utils.py: v = np.load(np_file)
./files/utils.py: v = np.load(np_file)
./files/utils.py: v = np.load(np_file)
./files/utils.py: d = np.load(os.path.join(path, name), allow_pickle=True)
./files/utils.py: weights = np.load(name)
./files/utils.py: return np.load(file_path).item()
./files/utils.py: return np.load(file_path)
Suggestion
Pass allow_pickle=True explicitly in all np.load(), it works as intended as I did so in my own environment.
New Issue Checklist
Issue Description
I encountered the following error when I was trying to run
python train.py
in repo tensorlayer/srgan.I did a little digging, and it turns out that recent development in numpy stated in numpy/numpy#13359 changed the default value of
allow_pickle
from True to False. A quickgrep
in tensorlayer folder suggested that mostnp.load()
did not explicitly passTrue
argument forallow_pickle
.Suggestion
Pass
allow_pickle=True
explicitly in allnp.load()
, it works as intended as I did so in my own environment.