explaingit

nvlabs/stylegan2

11,185PythonAudience · researcherComplexity · 5/5LicenseSetup · hard

TLDR

NVIDIA Research's AI model that generates photorealistic images of faces, cars, and animals from scratch, and can blend the visual style of two generated images together.

Mindmap

mindmap
  root((stylegan2))
    What it does
      Generates images
      Style mixing
      Model inversion
    Pre-trained Models
      Human faces
      Cars
      Cats
      Churches
    Tech Stack
      Python
      TensorFlow 1.14
      CUDA
      Docker
    Requirements
      16 GB GPU VRAM
      Linux recommended
      CUDA toolkit
    Audience
      AI researchers
      Computer vision
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate batches of photorealistic human face images at 1024×1024 resolution using a pre-trained model.

USE CASE 2

Blend visual characteristics, like hair and pose from one image with the skin tone of another, using style mixing.

USE CASE 3

Detect whether a photograph was generated by the StyleGAN2 model using its invertibility feature.

USE CASE 4

Reproduce the NVIDIA Research paper's image quality results to benchmark against your own generative model.

Tech stack

PythonTensorFlow 1.14CUDADocker

Getting it running

Difficulty · hard Time to first run · 1day+

Requires an NVIDIA GPU with at least 16 GB VRAM, the CUDA toolkit, and TensorFlow 1.14 or 1.15, TensorFlow 2 is not supported.

Non-commercial research use only under NVIDIA's custom license, commercial use is not permitted.

In plain English

StyleGAN2 is NVIDIA Research's official code release for a model that generates photorealistic images from scratch. The model is a generative adversarial network, a type of AI system trained to produce new images that look indistinguishable from real photographs. StyleGAN2 was released alongside a research paper that identified quality problems in the original StyleGAN model and proposed fixes for them. The code comes with pre-trained models for several categories: human faces (at 1024x1024 pixel resolution), cars, cats, churches, and horses. To generate new images, you point the code at one of those pre-trained model files and run a command that produces a batch of PNG images. A truncation setting controls the trade-off between variety and quality in the output. One notable capability is style mixing, where the visual characteristics of two different generated images can be blended together at varying degrees. This lets you combine, for example, the hair and pose of one generated face with the skin tone and age of another. The paper also notes that this version is significantly easier to invert, meaning you can detect whether a given image was produced by the model. Running this code requires a high-end NVIDIA graphics card with at least 16 gigabytes of memory, along with the CUDA toolkit and TensorFlow 1.14 or 1.15. TensorFlow 2 is not supported. The README recommends Linux, though Windows is also possible with some extra setup. A Docker configuration is included for those who prefer containers. A newer successor called StyleGAN2-ADA-PyTorch is noted in the README and available separately. This repository uses a custom NVIDIA license that permits non-commercial research use.

Copy-paste prompts

Prompt 1
Using the StyleGAN2 pre-trained faces model, generate 10 photorealistic face images and save them as PNGs. Show me the exact command to run.
Prompt 2
How do I perform style mixing with StyleGAN2? Give me the command to blend the style of image A with the content of image B at 50% mixing weight.
Prompt 3
Set up StyleGAN2 inside a Docker container on a Linux machine with an NVIDIA GPU, walk me through every step from cloning the repo to generating the first image.
Prompt 4
I want to check if a photo was generated by StyleGAN2, how do I use the model's inversion capability to test this?
Open on GitHub → Explain another repo

← nvlabs on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.