Skip to content

MB-29/optimal-textures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Optimal textures

An implementation of the texture generation algorithm proposed in Optimal Textures: Fast and Robust Texture Synthesis and Style Transfer through Optimal Transport.

Example

Texture generation

python run.py scale.jpg decoder_states/scale/ -n 5 

output

Style transfer

python run.py scale.jpg -c university.jpg decoder_states/scale/ -n 5 

output

Usage

  • In order to used pre-trained decoder weights, set up a directory containing .pth weight files with the form
Relu1_1_decoder_state.pth
Relu2_1_decoder_state.pth
Relu3_1_decoder_state.pth
Relu4_1_decoder_state.pth
Relu5_1_decoder_state.pth

If you want to train your decoders on your own image instead, this directory will be used to store the generated weights.

  • Set layer-specific parameters like the number of epoch and the learning rate for the decoders training phase, as well as iteration parameters in the dictionary observed_layers at the bottom of the file decoders.py.

  • Run the generation process with

python run.py path_to_source_image path_to_decoder_states_directory -o output_path -n n_passes [--train]
  • Run the style transfer process with
python run.py path_to_source_image path_to_decoder_states_directory -c path_to_content_image -s content_strength -o output_path -n n_passes [--train]

Requirements

  • Python 3
  • torch