Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StyleFlow (Windows 10) #18

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
945fb4a
Add files via upload
justinjohn0306 Jan 7, 2021
7f772f5
Add files via upload
justinjohn0306 Jan 7, 2021
c93058e
Add files via upload
justinjohn0306 Jan 7, 2021
a1fcb44
Add files via upload
justinjohn0306 Jan 7, 2021
e52a844
Add files via upload
justinjohn0306 Jan 7, 2021
6b62805
Add files via upload
justinjohn0306 Jan 7, 2021
1221288
Add files via upload
justinjohn0306 Jan 8, 2021
e1aafda
Add files via upload
justinjohn0306 Jan 8, 2021
1b4e039
Merge branch 'master' into master
justinjohn0306 Jan 18, 2021
ef56e9a
Add files via upload
justinjohn0306 Jan 19, 2021
696cb3a
Add files via upload
justinjohn0306 Jan 19, 2021
c2e3bd3
Update README.md
justinjohn0306 Feb 1, 2021
f0559fd
Update README.md
justinjohn0306 Feb 1, 2021
91883b7
Update README.md
justinjohn0306 Feb 1, 2021
4453532
Update README.md
justinjohn0306 Feb 1, 2021
e0ee796
Update README.md
justinjohn0306 Feb 1, 2021
b9c5a5a
Update README.md
justinjohn0306 Feb 1, 2021
999b9dc
Update README.md
justinjohn0306 Feb 10, 2021
8f825ad
Update README.md
justinjohn0306 Mar 26, 2021
2b67a5e
Update README.md
justinjohn0306 Mar 26, 2021
023aba6
Update README.md
justinjohn0306 Mar 26, 2021
8cf2485
Update README.md
justinjohn0306 Mar 26, 2021
b8a8949
Update README.md
justinjohn0306 Mar 26, 2021
83a815f
Update README.md
justinjohn0306 Mar 26, 2021
9571ef5
Add files via upload
justinjohn0306 Apr 29, 2021
95c233d
Update README.md
justinjohn0306 Apr 29, 2021
48110b7
Add files via upload
justinjohn0306 Apr 29, 2021
b7ec56d
Add files via upload
justinjohn0306 Apr 29, 2021
ee672b7
Add files via upload
justinjohn0306 Apr 29, 2021
df16023
Add files via upload
justinjohn0306 Apr 29, 2021
3d73aef
Add files via upload
justinjohn0306 Apr 29, 2021
9b91f70
Add files via upload
justinjohn0306 Apr 29, 2021
3a25933
Add files via upload
justinjohn0306 Apr 29, 2021
5ff22c9
Add files via upload
justinjohn0306 Apr 29, 2021
fa9e39e
Add files via upload
justinjohn0306 Apr 29, 2021
c2ac66b
Add files via upload
justinjohn0306 Apr 29, 2021
62767da
Add files via upload
justinjohn0306 Apr 29, 2021
a03b902
Add files via upload
justinjohn0306 Apr 29, 2021
b983b46
Add files via upload
justinjohn0306 Apr 29, 2021
6c0be82
Add files via upload
justinjohn0306 Apr 29, 2021
695d96c
Add files via upload
justinjohn0306 Apr 29, 2021
c454bab
Add files via upload
justinjohn0306 Apr 29, 2021
1e45b04
Update README.md
justinjohn0306 Apr 29, 2021
74f49d0
Update README.md
justinjohn0306 Apr 29, 2021
0ea31a1
Add files via upload
justinjohn0306 Apr 29, 2021
ed39732
Create __init__.py
justinjohn0306 Apr 29, 2021
49ec451
Delete __init__.py
justinjohn0306 Apr 29, 2021
d3eee45
Update README.md
justinjohn0306 Apr 29, 2021
d35eb3d
Update README.md
justinjohn0306 Apr 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 62 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# StyleFlow: Attribute-conditioned Exploration of StyleGAN-Generated Images using Conditional Continuous Normalizing Flows (ACM TOG 2021)

## See you @ Siggraph 2021
![Python 3.7](https://img.shields.io/badge/Python-3.7-green.svg?style=plastic)
![pytorch 1.1.0](https://img.shields.io/badge/Pytorch-1.1.0-green.svg?style=plastic)
![TensorFlow 1.15.0](https://img.shields.io/badge/TensorFlow-1.15.0-green.svg?style=plastic)
Expand All @@ -13,6 +13,7 @@ High-quality, diverse, and photorealistic images can now be generated by uncondi

> **StyleFlow: Attribute-conditioned Exploration of StyleGAN-Generated Images using Conditional Continuous Normalizing Flows (ACM TOG 2021)** <br>
> Rameen Abdal, Peihao Zhu, Niloy Mitra, Peter Wonka <br>
> KAUST, Adobe Research <br>



Expand All @@ -22,18 +23,41 @@ High-quality, diverse, and photorealistic images can now be generated by uncondi
[[Promotional Video](https://youtu.be/Lt4Z5oOAeEY)]


## Note: This repo works only in Windows 10



## Installation

Clone this repo.
```bash
git clone https://github.com/RameenAbdal/StyleFlow.git
git clone https://github.com/justinjohn0306/StyleFlow.git
cd StyleFlow/
```

This code requires PyTorch, TensorFlow, Torchdiffeq, Python 3+ and Pyqt5. Please install dependencies by
```bash
conda env create -f environment.yml
```
This code requires PyTorch, TensorFlow, Torchdiffeq, Python 3+ and Pyqt5.

Please install dependencies by following these instuctions properly:

1. conda env create -f env_windows.yml (Download and Install Anaconda): [Download Anaconda 64-Bit Graphical Installer]
(https://www.anaconda.com/products/individual)

2. conda activate styleflow

3. conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
[Also available here:(https://pytorch.org/get-started/previous-versions/)]

4. Download and Install Microsoft Visual Studio Community 2017 : [https://visualstudio.microsoft.com/vs/older-downloads]
Note: MSV17 is specifically required. MSVS19 won't work

Make sure to add Microsoft Visual Studio to Windows path
eg-: (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat)

5. add compiler_bindir_search_path inside custom_ops.py

(inside this folder: dnnlib\tflib)
eg: ('C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64',)


StyleGAN2 relies on custom TensorFlow ops that are compiled on the fly using [NVCC](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html). To correctly setup the StyleGAN2 generator follow the **Requirements** in [this repo](https://github.com/NVlabs/stylegan2).

Expand Down Expand Up @@ -87,18 +111,43 @@ xhost -local:docker
```


## Web UI (Beta)
A web based UI is also now available. The WebUI is based on [Streamlit](https://www.streamlit.io/) framework and is still in development phase. To get started, install streamlit from pip:
```bash
pip install streamlit
pip uninstall protobuf python3-protobuf
pip install --upgrade pip
pip install --upgrade protobuf
```
Then run the streamlit app located under webui/ folder as follows:
```bash
cd webui
streamlit run app.py
```
This should automatically open a new browser tab with the UI.

![image](./docs/assets/styleflow-web-final.gif)


## Training New Model
Dataset containing sampled StyleGAN2 latents, lighting SH parameters and other attributes. ([Download Here](https://drive.google.com/file/d/1opdzeqpYWtE1uexO49JI-3_RWfE9MYlN/view?usp=sharing))

To be added
Create `./data_numpy/` in the main folder and extract the above data or create your own dataset.

Train your model:
```bash
python train_flow.py
```
## Projection

Our new projection method is currently under review. To be updated!

## License

All rights reserved. Licensed under the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode) (**Attribution-NonCommercial-ShareAlike 4.0 International**) The code is released for academic research use only.
All rights reserved. Licensed under the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode) (**Attribution-NonCommercial-ShareAlike 4.0 International**). The code is released for academic research use only.

## Citation
If you use this research/codebase, please cite our papers.
If you use this research/codebase/dataset, please cite our papers.
```
@article{abdal2020styleflow,
title={Styleflow: Attribute-conditioned exploration of stylegan-generated images using conditional continuous normalizing flows},
Expand All @@ -119,5 +168,9 @@ If you use this research/codebase, please cite our papers.
pages={4431-4440},
doi={10.1109/ICCV.2019.00453}}
```

## Broader Impact
*Important* : Deep learning based facial imagery like DeepFakes and GAN generated images can be gravely misused. This can spread misinformation and lead to other offences. The intent of our work is not to promote such practices but instead be used in the areas such as identification (novel views of a subject, occlusion inpainting etc. ), security (facial composites etc.), image compression (high quality video conferencing at lower bitrates etc.) and development of algorithms for detecting DeepFakes.

## Acknowledgments
This implementation builds upon the awesome work done by Karras et al. ([StyleGAN2](https://github.com/NVlabs/stylegan2)), Chen et al. ([torchdiffeq](https://github.com/rtqichen/torchdiffeq)) and Yang et al. ([PointFlow](https://arxiv.org/abs/1906.12320)). This work was supported by Adobe Research and KAUST Office of Sponsored Research (OSR).
27 changes: 21 additions & 6 deletions dnnlib/tflib/custom_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,25 @@
verbose = True # Print status messages to stdout.

compiler_bindir_search_path = [
'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64',
'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64',
'C:/Program Files (x86)/Microsoft Visual Studio 14.0/vc/bin',
'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64',
]

#----------------------------------------------------------------------------
# Internal helper funcs.

def _find_compiler_bindir():

#Derive MSVC compiler path from compiler_bindir_search_path array
for compiler_path in compiler_bindir_search_path:
if os.path.isdir(compiler_path):
return compiler_path

#Derive MSVC compiler path from subdirectory tree
subdirectory_paths = [x[0] for x in os.walk('C:\\Program Files (x86)\\Microsoft Visual Studio\\')];
if subdirectory_paths is not None:
for directory_path in subdirectory_paths:
if _compiler_path_validator(directory_path):
return directory_path
return None

def _get_compute_cap(device):
Expand All @@ -61,9 +68,7 @@ def _run_cmd(cmd):
raise RuntimeError('NVCC returned an error. See below for full command line and output log:\n\n%s\n\n%s' % (cmd, output))

def _prepare_nvcc_cli(opts):
# cmd = 'nvcc ' + opts.strip()
cmd = '/usr/local/cuda/bin/nvcc --std=c++11 -DNDEBUG ' + opts.strip()

cmd = 'nvcc ' + opts.strip()
cmd += ' --disable-warnings'
cmd += ' --include-path "%s"' % tf.sysconfig.get_include()
cmd += ' --include-path "%s"' % os.path.join(tf.sysconfig.get_include(), 'external', 'protobuf_archive', 'src')
Expand All @@ -81,6 +86,16 @@ def _prepare_nvcc_cli(opts):
cmd += ' 2>&1'
return cmd

def _compiler_path_validator(path):
if path is not None:
if path[:76] == 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\' and path[-16:] == '\\bin\\Hostx64\\x64':
return True
elif path[:76] == 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\' and path[-16:] == '\\bin\\Hostx64\\x64':
return True
elif path == 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\vc\\bin':
return True
return False

#----------------------------------------------------------------------------
# Main entry point.

Expand Down
2 changes: 2 additions & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<div class="center" style="font-size: 26pt;color: white">
StyleFlow : Attribute-conditioned Exploration of StyleGAN-generated Images using
Conditional Continuous Normalizing Flows (ACM TOG 2021)
<div class="center" style="font-size: 18pt;color: white">
See you @ Siggraph 2021
<div class="author" style="font-size: 18pt;color: white">
<a href="https://scholar.google.com/citations?user=kEQimk0AAAAJ&hl=en" target="_blank">Rameen Abdal</a><sup>1</sup>&nbsp;
<a href="https://github.com/ZPdesu" target="_blank">Peihao Zhu</a><sup>1</sup>&nbsp;
Expand Down
Binary file added docs/assets/styleflow-web-final.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions env_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: styleflow
channels:
- pytorch
- anaconda
- defaults
dependencies:
- _pytorch_select=1.1.0=cpu
- _tflow_select=2.1.0=gpu
- absl-py=0.9.0=py36_0
- astor=0.8.0=py36_0
- blas=1.0=mkl
- ca-certificates=2020.12.8=haa95532_0
- certifi=2020.12.5=py36haa95532_0
- cffi=1.14.0=py36h7a1dbc1_0
- cloudpickle=1.4.1=py_0
- cycler=0.10.0=py36h009560c_0
- cytoolz=0.10.1=py36he774522_0
- dask-core=2.16.0=py_0
- decorator=4.4.2=py_0
- freetype=2.8=vc14h17c9bdf_0
- gast=0.3.3=py_0
- grpcio=1.27.2=py36h351948d_0
- h5py=2.7.1=py36he54a1c3_0
- hdf5=1.10.1=vc14hb361328_0
- icc_rt=2019.0.0=h0cc432a_1
- icu=58.2=vc14hc45fdbb_0
- imageio=2.8.0=py_0
- intel-openmp=2020.1=216
- jpeg=9b=vc14h4d7706e_1
- keras-applications=1.0.8=py_0
- keras-preprocessing=1.1.0=py_1
- kiwisolver=1.2.0=py36h74a9793_0
- libpng=1.6.37=h2a8f88b_0
- libprotobuf=3.11.4=h7bd577a_0
- libtiff=4.1.0=h56a325e_0
- markdown=3.1.1=py36_0
- mkl=2020.1=216
- mkl-service=1.1.2=py36hb217b18_5
- mkl_fft=1.0.6=py36hdbbee80_0
- mkl_random=1.0.1=py36h77b88f5_1
- networkx=2.4=py_0
- ninja=1.9.0=py36h74a9793_0
- numpy=1.15.4=py36ha559c80_0
- numpy-base=1.15.4=py36h8128ebf_0
- olefile=0.46=py_0
- openssl=1.1.1i=h2bbff1b_0
- pip=20.0.2=py36_3
- protobuf=3.11.4=py36h33f27b4_0
- pycparser=2.20=py_0
- pyparsing=2.4.7=py_0
- pyqt=5.9.2=py36h6538335_2
- python=3.6.7=h33f27b4_1
- python-dateutil=2.8.1=py_0
- pytz=2020.1=py_0
- pywavelets=1.1.1=py36he774522_0
- qt=5.9.7=vc14h73c81de_0
- scikit-image=0.16.2=py36h47e9c7a_0
- scipy=1.1.0=py36h4f6bf74_1
- setuptools=46.4.0=py36_0
- sip=4.19.8=py36h6538335_0
- six=1.14.0=py36_0
- sqlite=3.31.1=h2a8f88b_1
- tensorboard=1.14.0=py36he3c9ec2_0
- tensorflow=1.14.0=gpu_py36h305fd99_0
- tensorflow-base=1.14.0=gpu_py36h55fc52a_0
- tensorflow-estimator=1.14.0=py_0
- tensorflow-gpu=1.14.0=h0d30ee6_0
- termcolor=1.1.0=py36_1
- tk=8.6.7=vc14hb68737d_1
- toolz=0.10.0=py_0
- tornado=6.0.4=py36he774522_1
- vc=14.1=h0510ff6_4
- vs2015_runtime=14.16.27012=hf0eaf9b_1
- werkzeug=1.0.1=py_0
- wheel=0.34.2=py36_0
- wincertstore=0.2=py36h7fe50ca_0
- wrapt=1.12.1=py36he774522_1
- xz=5.2.5=h62dcd97_0
- zlib=1.2.11=vc14h1cdd9ab_1
- zstd=1.3.7=h508b16e_0
- pip:
- chardet==3.0.4
- dataclasses==0.8
- deprecated==1.2.10
- helpdev==0.7.1
- idna==2.9
- imagecodecs==2020.2.18
- importlib-metadata==1.6.0
- joblib==0.15.1
- matplotlib==3.2.1
- opencv-python==4.2.0.34
- pillow==7.1.2
- pyqt5==5.14.2
- pyqt5-sip==12.7.2
- qdarkgraystyle==1.0.2
- qdarkstyle==2.8.1
- qtpy==1.9.0
- requests==2.23.0
- scikit-learn==0.23.1
- threadpoolctl==2.0.0
- tifffile==2020.5.11
- torch==1.7.1
- torchdiffeq==0.0.1
- tqdm==4.48.0
- typing-extensions==3.7.4.3
- urllib3==1.25.9
- zipp==3.1.0

Binary file added flow_weight/modelsmall10k.pt
Binary file not shown.
Loading