This code release accompanies the following paper:
A cost-effective method for improving and re-purposing large, pre-trained GANs by fine-tuning their class-embeddings [Video] [arXiv]
Qi Li, Long Mai, Michael A. Alcorn, and Anh Nguyen. Asian Conference on Computer Vision (ACCV). 2020. Oral presentation. :star: Huawei Best Application Paper Honorable Mention. :star:
- Download the pre-trained BigGAN model weights (see here for an explanation of the commands):
cd biggan-am/pretrained_weights
# 128x128 weights.
fileid="1nAle7FCVFZdix2--ks0r5JBkFnKw8ctW"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o biggan_weights.zip
unzip biggan_weights.zip
rm biggan_weights.zip
# 256x256 weights.
fileid="1FEAXaUjRcV8mb0sHIwuS2EFyAcAITDTw"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o biggan_256_weights.pth
- Install the Python packages (we used Python 3.6):
cd biggan-am
pip3 install -r requirements.txt
Alternatively, you can use our provided Dockerfile
to run the model in a container:
cd biggan-am
docker build -t biggan-am:v1 .
nvidia-docker run \
-a stdin \
-a stdout \
-it \
--name biggan-am \
--mount type=bind,source=$(pwd),target=/biggan-am \
biggan-am:v1 \
/bin/bash
- Edit
opts.yaml
:
cd biggan-am
nano opts.yaml
- Run BigGAN-AM:
python3 biggan_am.py
cd biggan-am
python3 sample_biggan_am_embedding.py [directory] [target]
e.g.:
python3 sample_biggan_am_embedding.py "places" "266_pier"
If you find this work useful for your research, please consider citing:
@article{li2020improving,
title={A cost-effective method for improving and re-purposing large, pre-trained GANs by fine-tuning their class-embeddings},
author={Li, Qi and Mai, Long and Alcorn, Michael A. and Nguyen, Anh},
journal={Asian Conference on Computer Vision},
year={2020}
}
This work is supported by the National Science Foundation under Grant No. 1850117 and a donation from Adobe Inc.
Thanks to BigGAN-PyTorch by Andy Brock
robustness package by MadryLab
Places365-CNNs by MIT CSAIL