You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/alexandonian/paint-by-word.git
cd paint-by-word
Create python virtual environment
Install a recent version of PyTorch and other dependencies specified below.
We highly recommend that you install additional dependencies in an isolated python virtual environment (of your choosing). For Conda+pip users, you can create a new conda environment and then pip install dependencies with the following snippet:
frompaintbywordimportStyleganPainterfrompaintbyword.utilsimportshow, pilim# Create instance of painter classpainter=StyleganPainter(pretrained='birds')
seed_index=0z, image, loss_history, im_history=painter.paint(
seed_index,
'A photo of a yellow bird with black colored wings',
optim_method='cma + adam'
)
# Show the painted output image.show(pilim(image[0]))
should produce an image similar to the one below on the right with the optimization history on the left:
Masked painting with words
frompaintbywordimportStyleganMaskedPainterfrompaintbyword.utilsimportshow, pilim# Create instance of masked painter classpainter=StyleganMaskedPainter(pretrained='bedroom')
# Display grid of seed images to choose frompainter.show_seed_images(batch_size=32)
choice=30# Choose index of desired seed image.painter.mask_seed_image(choice) # Scribble mask on seed image.
result=painter.paint(
choice,
description='A photo of a rustic bed',
optim_method='cma + adam'
)
# Show the painted output image.show(pilim(image[0]))
For complete working examples, please see the juypter notebooks in the notebooks directory.
Citation
If you use this code for your research, please cite our paper.
@misc{bau2021paintbyword,
title={Paint by Word},
author={Alex Andonian and Sabrina Osmany and Audrey Cui and YeonHwan Park and Ali Jahanian and Antonio Torralba and David Bau},
year={2021},
eprint={arXiv:2103.10951},
}
}