yitong91 / StoryGAN

StoryGAN: A Sequential Conditional GAN for Story Visualization
233 stars 58 forks source link

ValueError: Object arrays cannot be loaded when allow_pickle=False #16

Open fdiskdc opened 4 years ago

fdiskdc commented 4 years ago

When I try to use python3.7 to train storygan it:

Please read https://msg.pyyam l.org/load for full details. yaml_cfg = edict(yaml.load(f)) Using config: {'CONFIG_NAME': 'StoryGAN', 'CUDA': True, 'DATASET_NAME': 'clevr', 'DATA_DIR': '', 'EMBEDDING_TYPE': 'cnn-rnn', 'GAN': {'CONDITION_DIM': 75, 'DF_DIM': 96, 'GF_DIM': 192, 'R_NUM': 4, 'Z_DIM': 100}, 'GPU_ID': '0', 'IMSIZE': 64, 'LABEL_NUM': 15, 'NET_D': '', 'NET_G': '', 'STAGE': 1, 'STAGE1_G': '', 'ST_WEIGHT': 1.0, 'TEXT': {'DIMENSION': 75}, 'TRAIN': {'COEFF': {'KL': 2.0}, 'DISCRIMINATOR_LR': 0.0002, 'FLAG': True, 'GENERATOR_LR': 0.0002, 'IM_BATCH_SIZE': 60, 'LR_DECAY_EPOCH': 20, 'MAX_EPOCH': 120, 'PRETRAINED_EPOCH': 600, 'PRETRAINED_MODEL': '', 'SNAPSHOT_INTERVAL': 10, 'ST_BATCH_SIZE': 24}, 'VIDEO_LEN': 4, 'VIS_COUNT': 10, 'WORKERS': 2, 'Z_DIM': 10} Traceback (most recent call last): File "main_clevr.py", line 81, in storydataset = data.StoryDataset(dir_path, video_transforms, cfg.VIDEO_LEN, True) File "C:\Users\12876\Documents\GAN - 副本\StoryGAN-master\code\clevr_data.py", line 15, in init self.descriptions = np.load(image_path +'CLEVR_dict.npy' ).item() File "C:\Users\12876\anaconda3\envs\python37\lib\site-packages\numpy\lib\npyio.py", line 453, in load pickle_kwargs=pickle_kwargs) File "C:\Users\12876\anaconda3\envs\python37\lib\site-packages\numpy\lib\format.py", line 739, in read_array raise ValueError("Object arrays cannot be loaded when " ValueError: Object arrays cannot be loaded when allow_pickle=False


That is my problem?

fdiskdc commented 4 years ago

I had changed the code.


image Change "iteritems"to"items"


image Change"if not b.has_key(k)"to" if k not in b:"


image change "np.load(A)"to "np.load(A,encoding=“latin1”)"


How can I fix it?

yitong91 commented 4 years ago

Can you try allow_pickle=True in the function np.load() and remove the encoding assignment? I think this is the compatibility issue caused python 2 and 3. My sample file (.npy) is stored as py2.