MCPcopy
hub / github.com/rosinality/vq-vae-2-pytorch

github.com/rosinality/vq-vae-2-pytorch @main sqlite

repository ↗ · DeepWiki ↗
114 symbols 302 edges 12 files 0 documented · 0%
README

vq-vae-2-pytorch

Implementation of Generating Diverse High-Fidelity Images with VQ-VAE-2 in PyTorch

Update

  • 2020-06-01

train_vqvae.py and vqvae.py now supports distributed training. You can use --n_gpu [NUM_GPUS] arguments for train_vqvae.py to use [NUM_GPUS] during training.

Requisite

  • Python >= 3.6
  • PyTorch >= 1.1
  • lmdb (for storing extracted codes)

Checkpoint of VQ-VAE pretrained on FFHQ

Usage

Currently supports 256px (top/bottom hierarchical prior)

  1. Stage 1 (VQ-VAE)

python train_vqvae.py [DATASET PATH]

If you use FFHQ, I highly recommends to preprocess images. (resize and convert to jpeg)

  1. Extract codes for stage 2 training

python extract_code.py --ckpt checkpoint/[VQ-VAE CHECKPOINT] --name [LMDB NAME] [DATASET PATH]

  1. Stage 2 (PixelSNAIL)

python train_pixelsnail.py [LMDB NAME]

Maybe it is better to use larger PixelSNAIL model. Currently model size is reduced due to GPU constraints.

Sample

Stage 1

Note: This is a training sample

Sample from Stage 1 (VQ-VAE)

Core symbols most depended-on inside this repo

step
called by 7
scheduler.py
encode
called by 7
vqvae.py
save
called by 3
scheduler.py
load_model
called by 3
sample.py
wn_linear
called by 3
pixelsnail.py
embed_code
called by 3
vqvae.py
decode
called by 3
vqvae.py
get_world_size
called by 3
distributed/distributed.py

Shape

Method 63
Class 26
Function 25

Languages

Python100%

Modules by API surface

scheduler.py38 symbols
pixelsnail.py26 symbols
vqvae.py19 symbols
distributed/distributed.py9 symbols
dataset.py6 symbols
train_pixelsnail.py4 symbols
pixelsnail_mnist.py4 symbols
distributed/launch.py3 symbols
train_vqvae.py2 symbols
sample.py2 symbols
extract_code.py1 symbols

For agents

$ claude mcp add vq-vae-2-pytorch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact