Skip to content

Variational Autoencoder to generate brick textures

Notifications You must be signed in to change notification settings

tlangmo/texture-vae

Repository files navigation

Texture VAE

Experiments generating textures using Variational Autoencoders (VAE).

Live Demo

VAEs have the benefit of fast inference, making them suitable to be deployed in the browser or games.

Texture Stiching

The VAE model can be used beyond simple sampling. Since the image generation is fully differentiateable, we can guide the image synthesis towards an objective. See notebooks/stich.ipynb

Stiched Bricks

Basic Requirements

  • Python >= 3.8
  • PyTorch >= 1.10.2
  • Linux OS
  • CUDA compatible GPU

Installation

# create venv and install dependencies
make setup

# download the training data
wget https://build-fitid-s3-bucket-download.s3.eu-central-1.amazonaws.com/motesque/bricks1000.zip
unzip bricks1000.zip

Configuration

model:
  latent_dims: 32
  texture_size: 128
  kl_weight: 0.7
lr: 1e-4
epochs: 500
snapshots: "../snapshots"
train_images: "../bricks1000"
logs:
  logdir: "../tb/runs"
  experiment_name: "default"

Usage

cd texture_vae
python train.py -c config.yml

Tensorboard

make tb

Http Dev Server with ONNX runtime

make http

Training Notes

The training images have been compiled from high-res Creative Commons Brick Textures sourced at Texture Ninja Each high-res texture was randomly cropped into 128x128 images using cli/crop_gen.py *

  • Latent code size does not have a dramatic effect. 32 seems to be enough
  • The KLD weigthing has a huge influence on the sampling quality. While a lower value does improve reconstruction, the sampled images are of bad quality then.

Reconstructed Bricks

Reconstructed Bricks

Sampled Bricks

Sampled Bricks

Learning Material

VAE Introductions

Interesting Papers

Code repos:

https://github.com/AntixK/PyTorch-VAE

About

Variational Autoencoder to generate brick textures

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published