Created
December 7, 2020 23:11
-
-
Save zachlewis/fdda93c8240bda166982dd360085bab6 to your computer and use it in GitHub Desktop.
ganspace rez package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "ganspace" | |
version = "0.1.2" | |
description = """ | |
GANSpace: Discovering Interpretable GAN Controls | |
Erik Härkönen, Aaron Hertzmann, Jaakko Lehtinen, Sylvain Paris | |
Aalto University, Adobe Research, NVIDIA | |
https://arxiv.org/abs/2004.02546 | |
Abstract: This paper describes a simple technique to analyze | |
Generative Adversarial Networks (GANs) and create interpretable | |
controls for image synthesis, such as change of viewpoint, aging, | |
lighting, and time of day. We identify important latent directions | |
based on Principal Components Analysis (PCA) applied in activation | |
space. Then, we show that interpretable edits can be defined based | |
on layer-wise application of these edit directions. Moreover, we show | |
that BigGAN can be controlled with layer-wise inputs in a StyleGAN-like | |
manner. A user may identify a large number of interpretable controls | |
with these mechanisms. We demonstrate results on GANs from various | |
datasets. | |
""" | |
authors = ["Härkönen", "Hertzmann", "lehtinen", "Paris"] | |
@early() | |
def variants(): | |
from rez.package_py_utils import expand_requires | |
requires = ["platform-**", "arch-**"] | |
pythons = [ | |
"python-3.7.*", | |
] | |
cudas = [ | |
"cuda-10.1", | |
#'cuda-10.2', | |
] | |
torches = [ | |
"torch-1.5.1", | |
#"torch-1.5.0", | |
] | |
tensorflows = ["tensorflow_gpu-2.1+<3"] | |
return [ | |
expand_requires(*requires + [python, cuda, torch, tf]) for torch in torches for tf in tensorflows | |
for cuda in cudas for python in pythons | |
] | |
hashed_variants = True | |
requires = [ | |
"scikit_learn", | |
"boto3", | |
"requests", | |
"tqdm", | |
"numpy", | |
"libsixel_python", | |
"tensorflow_hub", | |
"tensorflow_gpu", | |
"torch-1.5.0+", | |
"nltk", | |
"scikit_image", | |
"Pillow_SIMD", | |
"torchvision", | |
"pyopengltk", | |
"gflags", | |
#'glumpy', | |
#'PyQt5_sip' | |
] | |
private_build_requires = [ | |
"pip-19+", | |
"git", | |
"Cython", | |
"llvm-8", | |
#'libtorch', | |
#'gcc-6+<9', | |
] | |
def commands(): | |
python_ver = resolve.python.version | |
env.PATH.prepend("{root}/bin") | |
env.PYTHONPATH.prepend("{root}/lib/python{python_ver.major}.{python_ver.minor}/site-packages") | |
env.PYTHONPATH.append("{root}/ganspace") | |
env.PYTHONPATH.append("{root}/python") | |
alias("deploy_dnnlib", "cp -a {root}/python/dnnlib .") | |
@early() | |
def uuid(): | |
import uuid | |
return str(uuid.uuid5(uuid.NAMESPACE_DNS, name)) | |
def pre_build_commands(): | |
env.PYTHONUSERBASE = build.install_path | |
build_command = """ | |
#pip install glumpy --user --no-deps --no-compile | |
cp -a {root}/python $REZ_BUILD_INSTALL_PATH | |
mkdir -p $REZ_BUILD_INSTALL_PATH/etc | |
python -c "import nltk; nltk.download('wordnet', download_dir='$REZ_BUILD_INSTALL_PATH/etc')" | |
git clone https://github.com/harskish/ganspace.git | |
cd ganspace | |
git submodule update --init --recursive | |
cd models/stylegan2/stylegan2-pytorch | |
git remote add rosinality https://github.com/rosinality/stylegan2-pytorch.git | |
git commit -a -m 'merge upstream' | |
git pull rosinality master -ff | |
# compile and install stylegan2 fused ops for pytorch | |
cp {root}/setup/setup_fused.py ./op | |
cp {root}/setup/setup_upfirdn2d.py ./op | |
cd ../../../.. | |
cp {root}/setup_fused.py ./ganspace/models/stylegan2/stylegan2-pytorch/op/. | |
cp {root}/setup_upfirdn2d.py ./ganspace/models/stylegan2/stylegan2-pytorch/op/. | |
python ./ganspace/models/stylegan2/stylegan2-pytorch/op/setup_upfirdn2d.py build bdist_wheel | |
python ./ganspace/models/stylegan2/stylegan2-pytorch/op/setup_fused.py build bdist_wheel | |
pip install dist/upfirdn2d*.whl --user --no-deps --upgrade | |
pip install dist/fused*.whl --user --no-deps --upgrade | |
mkdir -p $REZ_BUILD_INSTALL_PATH/ganspace | |
cp -a ganspace/*.py $REZ_BUILD_INSTALL_PATH/ganspace | |
cp -a ./ganspace/netdissect $REZ_BUILD_INSTALL_PATH/python | |
cp -a ./ganspace/cache $REZ_BUILD_INSTALL_PATH/ganspace/. | |
cp -a ./ganspace/tests $REZ_BUILD_INSTALL_PATH/ganspace/. | |
cp -a ./ganspace/out $REZ_BUILD_INSTALL_PATH/ganspace/. | |
cp ./ganspace/utils.py ./ganspace/models/. | |
sed -i 's/from utils import/from .utils import/g' ./ganspace/models/wrapper.py | |
cp -a ./ganspace/models $REZ_BUILD_INSTALL_PATH/ganspace/. | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment