THE ULTIMATE GUIDE TO STYLEGAN2 CUSTOM TRAINING

Опубликовано: 10 Июль 2026
на канале: cyremur
6,671
202

A comprehensive step-by-step guide for training a stylegan2 model based on your own image selection.


Business Inquiries: [email protected]
Follow me on Instagram:   / cyremur  
Support this channel:   / cyremur  


TUTORIAL WRITEUP AND OVERVIEW

00:00 intro skit

00:32 overview

03:10 preprocessing images

get image details:
identify image.jpg

convert to valid stylegan2 input:
mogrify -verbose -type truecolor -format jpg -thumbnail 512x512^ -gravity center -extent 512x512 image.jpg
(replace resolution as desired, use * [wildcard] for all images in folder)

12:31 parallel preprocessing performance

install parallel:
sudo apt install parallel

execute 'command' on every file:
ls -1 | parallel command {}

convert all images in parallel:

ls -1 | parallel mogrify -verbose -type truecolor -format jpg -thumbnail 512x512^ -gravity center -extent 512x512 {}

note: parallel manages 100% CPU load and converts images faster

19:00 image import to tfrecords

load stylegan2 environment:
ndocker stylegan2
(if you followed setup guide:    • THE ULTIMATE STYLEGAN2 DOCKER SETUP GUIDE ...  )

go to stylegan2 folder:
cd home
cd stylegan2

import images to tfrecords:
python dataset_tool.py create_from_images /home/datasets/MET500 /home/imagesets/MET500
(adjust paths as needed)

23:14 starting the training

execute in stylegan2 folder:
python run_training.py --data-dir=/home/datasets --dataset=MET500 --config=config-f
(adjust path as needed)

here the video explains the console output

32:48 explaining script arguments

explains the args of the run_training.py command
disables time consuming metrics by setting fid50k to none in run_training.py

40:06 resuming training (vanilla)

edit the training_loop.py file:
set resume_pkl = "{path-to-your-snapshot.pkl}"
set resume_kimg = "{latest-kimg-of-your-snapshot}"

46:42 adjusting snapshot frequency

finding the snapshot code and tracing the variables
adjusting network_snapshot_ticks variable, which gives snapshot frequency

50:38 resuming training (easy mode)

presents a fork of stylegan2 with patched command line args
downloading the patched stylegan2:
git clone https://github.com/ashirviskas/stylegan2

shows how to resume training with the patched version

58:27 outro