Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization

Unofficial pytorch-lightning implementation of a paper, "Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization"

Requirements

  • torch==1.10.1
  • torchvision==0.11.2
  • pytorch-lightning==1.5.7
  • tqdm==4.62.3
  • wandb==0.12.10
  • opencv-python-headless==4.5.5.62
  • easydict==1.9
  • onnxruntime==1.10.0

Install requirements by pip

pip install -r requirements.txt 

Install dependency by docker

docker-compose up -d 

Pretrained weights / models download

  • Encoder(VGG) weights download by "pytorch-AdaIN" repo
  • Decoder weights download by link
  • Net Torchscript model download by link
  • Net onnx model download by link

Dataset

Training

  1. download dataset (content, style)
  2. download Encoder weights and mv to weights dir
  3. check dataset path
  4. run script
python main.py \
--content_root_dir="{YOUR CONTENT DATASET PATH}" \
--style_root_dir="{YOUR STYLE DATASET PATH}" \
--num_workers=8 \
--batch_size=8 \
--log_every_n_steps=5 \
--gpus=1 \
--max_steps=16000

Training result

result plot, images

loss plot

content_loss style_loss

sample images

video

APP

Streamlit app source code referenced "Neural-Style-Transfer-Streamlit "

app_01 app_02

Menual

1. Download "Torchscript" model to "app/src" directory

2. Install APP dependency by pip

cd app
pip install -r requirements.txt 
  • torch==1.10.1
  • torchvision==0.11.2
  • pytorch-lightning==1.5.7
  • streamlit==1.7.0
  • opencv-python-headless==4.5.5.62

2. Install AdaIN app by docker

2.1. docker env

  • MODEL_PATH : torchscript file path

2.2. Start container

cd app
docker-compose up -d 

References