Giter Club home page Giter Club logo

Comments (5)

Wentong-DST avatar Wentong-DST commented on July 16, 2024

I have the same problem, anyone has any advice?

from stackgan-pytorch.

dhyaaalayed avatar dhyaaalayed commented on July 16, 2024

@314rated @Wentong-DST have you solved the problem, cuz I'm trying to solve it too

from stackgan-pytorch.

schreven avatar schreven commented on July 16, 2024

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.

from stackgan-pytorch.

harbarex avatar harbarex commented on July 16, 2024

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, '�'.

from stackgan-pytorch.

FlowerRoad1996 avatar FlowerRoad1996 commented on July 16, 2024

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!

from stackgan-pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.