Comments (3)
hello @MeteoRex11 did you solve this problem ? I am facing the same problem, please help me
from t2f.
You would need to store text in torch file format, with text embeddings already in them. This is a very tedious process, hence I did not make a script for it
from t2f.
I got it working after few cpu specific modifications for my laptop, using below:
Referred from: An IPYNB
Note: Depending upon PT version, few minor changes might be required
After importing your condition augmentor, text encoder and gan generator...
import pickle
file_name = 'path/to/your/.pkl'
obj = None
# obj = pickle.loads(open(file_name, 'rb').read())
with open(file_name, "rb") as pick:
obj = pickle.loads(pick.read())
max_caption_len = 100
in_str = input('Enter your caption : ')
in_str_tok = in_str.replace('_', ' ').split()
in_ind_list = [obj['rev_vocab'][in_str.strip()] for in_str in in_str_tok if in_str.strip() in obj['rev_vocab']]
caption = in_ind_list
full_str = []
for ind in caption:
full_str.append(obj['vocab'][ind])
str_proc = filter('<pad>'.__ne__, full_str)
if len(caption) < max_caption_len:
while len(caption) != max_caption_len:
caption.append(obj['rev_vocab']["<pad>"])
elif len(caption) > max_caption_len:
caption = caption[: max_caption_len]
fixed_captions = th.tensor([caption], dtype=th.long)
print("Text initialized!")
fixed_embeddings = text_encoder(fixed_captions)
fixed_embeddings = th.from_numpy(fixed_embeddings.detach().cpu().data.numpy()).to(device)
fixed_c_not_hats, mus, _ = condition_augmenter(fixed_embeddings)
fixed_noise = th.zeros(len(fixed_captions), c_pro_gan.latent_size - fixed_c_not_hats.shape[-1]).to(device)
fixed_gan_input = th.cat((fixed_c_not_hats, fixed_noise), dim=-1)
print("Gan input prepared")
And then...
import matplotlib.pyplot as plt
%matplotlib inline
create_grid(
samples=c_pro_gan.gen(
fixed_gan_input,
4,
1.0
),
scale_factor=1,
img_file='output.png')
img = plt.imread('output.png')
plt.figure()
plt.imshow(img)
from t2f.
Related Issues (20)
- Include the pytorch model of the final trained stage in the repo!
- I am getting this error and I checked out 1 parameter was passed in Losses.py. Can you help
- missing json HOT 5
- RuntimeError: Expected object of backend CUDA but got backend CPU for argument #3 'index' HOT 2
- Image generated not good, not even comparable. HOT 4
- TypeError: __init__() got an unexpected keyword argument 'embedding_size' HOT 2
- RuntimeError: Expected object of type torch.cuda.LongTensor but found type torch.LongTensor for argument #3 'index' HOT 2
- Generator Evaluation Metric
- Use this repo or wait for v2? HOT 2
- python version incompatibility
- Find/Create an open dataset HOT 1
- Mode collapse
- should use torch==0.4.1 rather than 0.4.0
- Broken code in train_network.py
- Slack Group for GAN / Deep RL enthusiasts. HOT 1
- Code error HOT 3
- TypeError: __init__() got an unexpected keyword argument 'embedding_size' HOT 6
- RuntimeError: cuDNN version incompatibility: PyTorch was compiled against 7401 but linked against 7301
- Trying a new data set which has around 200K face images and atrributes.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from t2f.