## Alias-Free Generative Adversarial Networks (StyleGAN3)<br><sub>Official PyTorch implementation of the NeurIPS 2021 paper</sub>
![Teaser image](./docs/stylegan3-teaser-1920x1006.png)
**Alias-Free Generative Adversarial Networks**<br>
Tero Karras, Miika Aittala, Samuli Laine, Erik Härkönen, Janne Hellsten, Jaakko Lehtinen, Timo Aila<br>
https://nvlabs.github.io/stylegan3<br>
Abstract: *We observe that despite their hierarchical convolutional nature, the synthesis process of typical generative adversarial networks depends on absolute pixel coordinates in an unhealthy manner. This manifests itself as, e.g., detail appearing to be glued to image coordinates instead of the surfaces of depicted objects. We trace the root cause to careless signal processing that causes aliasing in the generator network. Interpreting all signals in the network as continuous, we derive generally applicable, small architectural changes that guarantee that unwanted information cannot leak into the hierarchical synthesis process. The resulting networks match the FID of StyleGAN2 but differ dramatically in their internal representations, and they are fully equivariant to translation and rotation even at subpixel scales. Our results pave the way for generative models better suited for video and animation.*
For business inquiries, please visit our website and submit the form: [NVIDIA Research Licensing](https://www.nvidia.com/en-us/research/inquiries/)
## Release notes
This repository is an updated version of [stylegan2-ada-pytorch](https://github.com/NVlabs/stylegan2-ada-pytorch), with several new features:
- Alias-free generator architecture and training configurations (`stylegan3-t`, `stylegan3-r`).
- Tools for interactive visualization (`visualizer.py`), spectral analysis (`avg_spectra.py`), and video generation (`gen_video.py`).
- Equivariance metrics (`eqt50k_int`, `eqt50k_frac`, `eqr50k`).
- General improvements: reduced memory usage, slightly faster training, bug fixes.
Compatibility:
- Compatible with old network pickles created using [stylegan2-ada](https://github.com/NVlabs/stylegan2-ada) and [stylegan2-ada-pytorch](https://github.com/NVlabs/stylegan2-ada-pytorch). (Note: running old StyleGAN2 models on StyleGAN3 code will produce the same results as running them on stylegan2-ada/stylegan2-ada-pytorch. To benefit from the StyleGAN3 architecture, you need to retrain.)
- Supports old StyleGAN2 training configurations, including ADA and transfer learning. See [Training configurations](./docs/configs.md) for details.
- Improved compatibility with Ampere GPUs and newer versions of PyTorch, CuDNN, etc.
## Synthetic image detection
While new generator approaches enable new media synthesis capabilities, they may also present a new challenge for AI forensics algorithms for detection and attribution of synthetic media. In collaboration with digital forensic researchers participating in DARPA's SemaFor program, we curated a synthetic image dataset that allowed the researchers to test and validate the performance of their image detectors in advance of the public release. Please see [here](https://github.com/NVlabs/stylegan3-detector) for more details.
## Additional material
- [Result videos](https://nvlabs-fi-cdn.nvidia.com/stylegan3/videos/)
- [Curated example images](https://nvlabs-fi-cdn.nvidia.com/stylegan3/images/)
- [StyleGAN3 pre-trained models](https://ngc.nvidia.com/catalog/models/nvidia:research:stylegan3) for config T (translation equiv.) and config R (translation and rotation equiv.)
> <sub>Access individual networks via `https://api.ngc.nvidia.com/v2/models/nvidia/research/stylegan3/versions/1/files/<MODEL>`, where `<MODEL>` is one of:</sub><br>
> <sub>`stylegan3-t-ffhq-1024x1024.pkl`, `stylegan3-t-ffhqu-1024x1024.pkl`, `stylegan3-t-ffhqu-256x256.pkl`</sub><br>
> <sub>`stylegan3-r-ffhq-1024x1024.pkl`, `stylegan3-r-ffhqu-1024x1024.pkl`, `stylegan3-r-ffhqu-256x256.pkl`</sub><br>
> <sub>`stylegan3-t-metfaces-1024x1024.pkl`, `stylegan3-t-metfacesu-1024x1024.pkl`</sub><br>
> <sub>`stylegan3-r-metfaces-1024x1024.pkl`, `stylegan3-r-metfacesu-1024x1024.pkl`</sub><br>
> <sub>`stylegan3-t-afhqv2-512x512.pkl`</sub><br>
> <sub>`stylegan3-r-afhqv2-512x512.pkl`</sub><br>
- [StyleGAN2 pre-trained models](https://ngc.nvidia.com/catalog/models/nvidia:research:stylegan2) compatible with this codebase
> <sub>Access individual networks via `https://api.ngc.nvidia.com/v2/models/nvidia/research/stylegan2/versions/1/files/<MODEL>`, where `<MODEL>` is one of:</sub><br>
> <sub>`stylegan2-ffhq-1024x1024.pkl`, `stylegan2-ffhq-512x512.pkl`, `stylegan2-ffhq-256x256.pkl`</sub><br>
> <sub>`stylegan2-ffhqu-1024x1024.pkl`, `stylegan2-ffhqu-256x256.pkl`</sub><br>
> <sub>`stylegan2-metfaces-1024x1024.pkl`, `stylegan2-metfacesu-1024x1024.pkl`</sub><br>
> <sub>`stylegan2-afhqv2-512x512.pkl`</sub><br>
> <sub>`stylegan2-afhqcat-512x512.pkl`, `stylegan2-afhqdog-512x512.pkl`, `stylegan2-afhqwild-512x512.pkl`</sub><br>
> <sub>`stylegan2-brecahad-512x512.pkl`, `stylegan2-cifar10-32x32.pkl`</sub><br>
> <sub>`stylegan2-celebahq-256x256.pkl`, `stylegan2-lsundog-256x256.pkl`</sub><br>
## Requirements
* Linux and Windows are supported, but we recommend Linux for performance and compatibility reasons.
* 1–8 high-end NVIDIA GPUs with at least 12 GB of memory. We have done all testing and development using Tesla V100 and A100 GPUs.
* 64-bit Python 3.8 and PyTorch 1.9.0 (or later). See https://pytorch.org for PyTorch install instructions.
* CUDA toolkit 11.1 or later. (Why is a separate CUDA toolkit installation required? See [Troubleshooting](./docs/troubleshooting.md#why-is-cuda-toolkit-installation-necessary)).
* GCC 7 or later (Linux) or Visual Studio (Windows) compilers. Recommended GCC version depends on CUDA version, see for example [CUDA 11.4 system requirements](https://docs.nvidia.com/cuda/archive/11.4.1/cuda-installation-guide-linux/index.html#system-requirements).
* Python libraries: see [environment.yml](./environment.yml) for exact library dependencies. You can use the following commands with Miniconda3 to create and activate your StyleGAN3 Python environment:
- `conda env create -f environment.yml`
- `conda activate stylegan3`
* Docker users:
- Ensure you have correctly installed the [NVIDIA container runtime](https://docs.docker.com/config/containers/resource_constraints/#gpu).
- Use the [provided Dockerfile](./Dockerfile) to build an image with the required library dependencies.
The code relies heavily on custom PyTorch extensions that are compiled on the fly using NVCC. On Windows, the compilation requires Microsoft Visual Studio. We recommend installing [Visual Studio Community Edition](https://visualstudio.microsoft.com/vs/) and adding it into `PATH` using `"C:\Program Files (x86)\Microsoft Visual Studio\<VERSION>\Community\VC\Auxiliary\Build\vcvars64.bat"`.
See [Troubleshooting](./docs/troubleshooting.md) for help on common installation and run-time problems.
## Getting started
Pre-trained networks are stored as `*.pkl` files that can be referenced using local filenames or URLs:
```.bash
# Generate an image using pre-trained AFHQv2 model ("Ours" in Figure 1, left).
python gen_images.py --outdir=out --trunc=1 --seeds=2 \
--network=https://api.ngc.nvidia.com/v2/models/nvidia/research/stylegan3/versions/1/files/stylegan3-r-afhqv2-512x512.pkl
# Render a 4x2 grid of interpolations for seeds 0 through 31.
python gen_video.py --output=lerp.mp4 --trunc=1 --seeds=0-31 --grid=4x2 \
--network=https://api.ngc.nvidia.com/v2/models/nvidia/research/stylegan3/versions/1/files/stylegan3-r-afhqv2-512x512.pkl
```
Outputs from the above commands are placed under `out/*.png`, controlled by `--outdir`. Downloaded network pickles are cached under `$HOME/.cache/dnnlib`, which can be overridden by setting the `DNNLIB_CACHE_DIR` environment variable. The default PyTorch extension build directory is `$HOME/.cache/torch_extensions`, which
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
PyTorch官方目前尚未正式实现StyleGAN3,但可以通过将StyleGAN3的官方实现或开源实现转换为PyTorch代码来使用。下面是对StyleGAN3的概念和PyTorch实现的一些解释: 1. **StyleGAN3概念**: - StyleGAN3是生成对抗网络(GAN)的一种变体,用于生成高质量逼真的图像。它是对前代模型StyleGAN和StyleGAN2的改进版本,通过引入多样性并提升模型的可控性,进一步优化生成图像的质量和细节。 2. **PyTorch实现**: - 尽管PyTorch官方目前不提供StyleGAN3的正式实现,但开发者可以根据StyleGAN3的论文和相关开源代码(如GitHub上的非官方实现),自行将其转换为PyTorch代码实现。 - 这涉及到理解StyleGAN3的网络结构、损失函数和训练过程,并使用PyTorch中的模型定义和优化器等工具来实现相应的模块和算法。 3. **迁移学习和预训练模型**: - 利用已经训练好的StyleGAN3权重参数作为预训练模型(Pretrained Model),.....
资源推荐
资源详情
资源评论
收起资源包目录
PyTorch正式实现StyleGAN3.zip (81个子文件)
stylegan3-main
dataset_tool.py 18KB
metrics
__init__.py 448B
equivariance.py 11KB
perceptual_path_length.py 5KB
metric_main.py 6KB
precision_recall.py 4KB
metric_utils.py 12KB
kernel_inception_distance.py 2KB
frechet_inception_distance.py 2KB
inception_score.py 2KB
.github
ISSUE_TEMPLATE
bug_report.md 1005B
LICENSE.txt 4KB
viz
__init__.py 448B
pickle_widget.py 7KB
stylemix_widget.py 3KB
performance_widget.py 3KB
equivariance_widget.py 6KB
latent_widget.py 4KB
trunc_noise_widget.py 4KB
layer_widget.py 9KB
capture_widget.py 4KB
renderer.py 15KB
gen_video.py 7KB
gen_images.py 6KB
docs
troubleshooting.md 2KB
dataset-tool-help.txt 3KB
stylegan3-teaser-1920x1006.png 1.74MB
train-help.txt 3KB
visualizer_screen0.png 1.2MB
configs.md 24KB
visualizer_screen0_half.png 498KB
avg_spectra_screen0.png 375KB
avg_spectra_screen0_half.png 219KB
gui_utils
__init__.py 448B
imgui_window.py 4KB
text_utils.py 6KB
glfw_window.py 8KB
imgui_utils.py 6KB
gl_utils.py 16KB
Dockerfile 717B
environment.yml 393B
visualizer.py 14KB
legacy.py 16KB
dnnlib
__init__.py 488B
util.py 17KB
training
__init__.py 448B
training_loop.py 21KB
loss.py 8KB
dataset.py 8KB
networks_stylegan2.py 39KB
augment.py 26KB
networks_stylegan3.py 26KB
calc_metrics.py 8KB
train.py 16KB
README.md 21KB
torch_utils
__init__.py 448B
custom_ops.py 6KB
training_stats.py 10KB
misc.py 11KB
ops
filtered_lrelu.py 13KB
__init__.py 448B
filtered_lrelu_wr.cu 2KB
filtered_lrelu.cu 66KB
bias_act.h 1KB
upfirdn2d.cu 23KB
filtered_lrelu_rd.cu 2KB
conv2d_gradfix.py 10KB
fma.py 2KB
conv2d_resample.py 7KB
filtered_lrelu.h 4KB
upfirdn2d.py 16KB
bias_act.cpp 4KB
bias_act.py 10KB
grid_sample_gradfix.py 3KB
filtered_lrelu_ns.cu 2KB
upfirdn2d.cpp 5KB
filtered_lrelu.cpp 15KB
bias_act.cu 6KB
upfirdn2d.h 2KB
persistence.py 10KB
avg_spectra.py 12KB
共 81 条
- 1
资源评论
百锦再@新空间代码工作室
- 粉丝: 1w+
- 资源: 806
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功