Open 314rated opened 6 years ago
I have the same problem, anyone has any advice?
@314rated @Wentong-DST have you solved the problem, cuz I'm trying to solve it too
You can load val_captions.t7 with torchfile.load(val_captions.t7). It's a torchfile.hashable_unique_dict with two keys: raw_txt (a list texts) and fea_txt (a list of embeddings each of size 1024).
If you already have your custom embeddings you just have to follow that structure. I wanted to use python and not lua so torchfile.hashable_unique_dict was not appropriate. I used a regular dict instead and changed trainer.py at line 243 as:
t_file = torchfile.load(datapath) <<t_file = torch.load(datapath) captions_list = t_file.raw_txt <<captions_list = t_file['raw_txt'] embeddings = np.concatenate(t_file.fea_txt, axis=0) <<embeddings = np.concatenate(t_file['fea_txt'], axis=0)
This worked, but I would still be curious on how to generate the char-CNN-RNN text embeddings.
You can load val_captions.t7 with torchfile.load(val_captions.t7). It's a torchfile.hashable_unique_dict with two keys: raw_txt (a list texts) and fea_txt (a list of embeddings each of size 1024).
If you already have your custom embeddings you just have to follow that structure. I wanted to use python and not lua so torchfile.hashable_unique_dict was not appropriate. I used a regular dict instead and changed trainer.py at line 243 as:
t_file = torchfile.load(datapath) <<t_file = torch.load(datapath) captions_list = t_file.raw_txt <<captions_list = t_file['raw_txt'] embeddings = np.concatenate(t_file.fea_txt, axis=0) <<embeddings = np.concatenate(t_file['fea_txt'], axis=0)
This worked, but I would still be curious on how to generate the char-CNN-RNN text embeddings.
Is there any way to select only a few of the captions and embeddings from the val_captions.t7?
Also, I am getting the following error when I try your solution:
Traceback (most recent call last):
File "main.py", line 77, in <module>
algo.sample(datapath, cfg.STAGE)
File "C:\Users\hunte\OneDrive\Documents\Projects\EAD Project\StackGAN-Pytorch-master\code\trainer.py", line 242, in sample
t_file = torch.load(datapath)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py", line 387, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\serialization.py", line 564, in _load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, ''.
You can load val_captions.t7 with torchfile.load(val_captions.t7). It's a torchfile.hashable_unique_dict with two keys: raw_txt (a list texts) and fea_txt (a list of embeddings each of size 1024).
If you already have your custom embeddings you just have to follow that structure. I wanted to use python and not lua so torchfile.hashable_unique_dict was not appropriate. I used a regular dict instead and changed trainer.py at line 243 as:
t_file = torchfile.load(datapath) <<t_file = torch.load(datapath) captions_list = t_file.raw_txt <<captions_list = t_file['raw_txt'] embeddings = np.concatenate(t_file.fea_txt, axis=0) <<embeddings = np.concatenate(t_file['fea_txt'], axis=0)
This worked, but I would still be curious on how to generate the char-CNN-RNN text embeddings.
do you have a val_captions.t7 file,Icannot find this file and do not know the contents of this file...So i cannot eval my training result.Thank you!
Hi, I am using the pretrained COCO model, which is shared in this repo. How can I use it over some other sentences as input? Since the mode will not be train, it will use val_captions.t7. However, I am not clear on how to convert a text file to t7 file. Could you please elaborate on this? Thanks