Skip to content
StyleGAN - Official TensorFlow Implementation
Python Jupyter Notebook
Branch: master
Clone or download
Pull request Compare This branch is 4 commits ahead of halcy:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dnnlib
metrics Initial commit. Feb 5, 2019
training Initial commit. Feb 5, 2019
.gitignore Add Bottle server. Jul 1, 2019
LICENSE.txt
README.md Update README.md Jun 28, 2019
Stylegan-Generate-Encode.ipynb Improve interactive modification Mar 2, 2019
Stylegan-Interactive-Modification.ipynb
animate_mouth.py
bottle_server.py Add Bottle server. Jul 1, 2019
config.py
dataset_tool.py
generate_figures.py
mod_latents.npy Add interactive modification Mar 2, 2019
pretrained_example.py Initial commit. Feb 5, 2019
run_metrics.py
stylegan-teaser.png Initial commit. Feb 5, 2019
tag_dirs.pkl Add modification code and directions Feb 25, 2019
tags_use.pkl Add interactive modification Mar 2, 2019
train.py

README.md

Script to animate the mouth position of StyleGAN output from an audio file.

Install

ffmpeg and NVIDIA CUDA drivers must be installed.

Prepare Python Environment

conda create -n animate pip python=3.7
conda activate animate
pip install tensorflow-gpu pillow requests sklearn pydub

Download a StyleGAN model file, like:

Usage

python animate_mouth.py <MP3 path> <Model path> <Output path>

Eg:

python animate_mouth.py ~/data/presentday.mp3 ~/data 2019-04-30-stylegan-danbooru2018-portraits-02095-066083.pkl presentday.mp4

Arguments:

usage: animate_mouth.py [-h] [--psi PSI] [--truncate_pre TRUNCATE_PRE]
                        [--truncate_post TRUNCATE_POST]
                        [--output_dir OUTPUT_DIR] [--delete_imgs DELETE_IMGS]
                        [--randomize_noise RANDOMIZE_NOISE] [--seed SEED]
                        audio stylegan output

positional arguments:
  audio                 The filename of the audio file.
  stylegan              The filename of the StyleGAN pkl file.
  output                Set output filename of ffmpeg

optional arguments:
  -h, --help            show this help message and exit
  --psi PSI             The truncation psi. Default 0.7.
  --truncate_pre TRUNCATE_PRE
                        Truncate before dlatent modification. Default True.
  --truncate_post TRUNCATE_POST
                        Truncate after dlatent modification. Default True.
  --output_dir OUTPUT_DIR
                        Directory to output images to.
  --randomize_noise RANDOMIZE_NOISE
                        Whether to randomize the noise every step. Default False.
  --seed SEED           Random seed. 

Notes

The audio amplitude to mouth position mapping is pretty basic and could use some improvement.

See https://github.com/NVlabs/stylegan for original README. Tags from https://github.com/halcy/stylegan.

You can’t perform that action at this time.