Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

🎨 Docker images with set-up style transfer environments

License

Notifications You must be signed in to change notification settings

jtomori/style_transfer_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Style transfer Docker images

Docker images with set-up style transfer environments


What is inside

This repository contains two images:

  1. neural-fast-style-transfer containing:

  2. chainer-style-transfer containing:

  • the following files are not included:
    • coco2014 dataset needed for training new models for fast-style-transfer and chainer-fast-neuralstyle

Requirements


Running

  • Entering into interactive bash

    $ docker run -ti --rm --runtime=nvidia jtomori/neural-fast-style-transfer bash
    $ docker run -ti --rm --runtime=nvidia jtomori/chainer-style-transfer bash
  • Command structure: append your style transfer command at the end:

    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/neural-fast-style-transfer [your command here]

    This will mount host system working directory into /app/work in container. File structure in the container looks like this in neural-fast-style-transfer

    |--- app/
         |--- work/ (working directory)
         |--- neural-style/
         |--- fast-style-transfer/
         |--- imagenet-vgg-verydeep-19.mat
    

    and like this in chainer-style-transfer

    |--- app/
         |--- work/ (working directory)
         |--- chainer-fast-neuralstyle/
    

  • Run style transfer on included example images
    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/neural-fast-style-transfer python ../neural-style/neural_style.py --network ../imagenet-vgg-verydeep-19.mat --content ../neural-style/examples/1-content.jpg --styles ../neural-style/examples/1-style.jpg --output test.jpg --iterations 10
        ```
    This should produce `test.jpg` image in current working directory
    
  • Run style transfer on your own images
    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/neural-fast-style-transfer python ../neural-style/neural_style.py --network ../imagenet-vgg-verydeep-19.mat --content content.jpg --styles style.jpg --output test.jpg --iterations 10
    This will transfer style of style.jpg onto content.jpg resulting in test.jpg in current host working directory.

  • Run style transfer on included example image with model la_muse.ckpt

    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/neural-fast-style-transfer python ../fast-style-transfer/evaluate.py --checkpoint ../fast-style-transfer/examples/models/la_muse.ckpt --in-path ../fast-style-transfer/examples/content/chicago.jpg --out-path test.jpg
    

    This will transfer style of example model la_muse.ckpt on example image provided with the repository resulting in test.jpg. You can replace ../fast-style-transfer/examples/content/chicago.jpg with content.jpg to apply style on content.jpg in your current host directory.

    Included example models:

    • la_muse.ckpt
    • rain_princess.ckpt
    • scream.ckpt
    • udnie.ckpt
    • wave.ckpt
    • wreck.ckpt
  • Train a new model based on style.jpg

    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/neural-fast-style-transfer python ../fast-style-transfer/style.py --vgg-path ../imagenet-vgg-verydeep-19.mat --style style.jpg --checkpoint-dir model --train-path dataset

    Note that you need to pass path to coco2014 dataset, which is not included in the Docker image. In this case it is dataset folder in host working directory. model directory also needs to be created there.


  • Run style transfer on included example image and model, which will result in test.jpg in your curent host working directory

    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/chainer-style-transfer python3 ../chainer-fast-neuralstyle/generate.py ../chainer-fast-neuralstyle/sample_images/tubingen.jpg -m ../chainer-fast-neuralstyle/models/composition.model -o test.jpg -g 0

    Included example models:

    • composition.model
    • seurat.model

    Note: You can use --memory 7000m optional argument, which limits containers memory usage. Set it accordingly to your free memory if you encounter system crashes.

  • Train a new model

    $ docker run -v "$(pwd)":/app/work -ti --rm --runtime=nvidia jtomori/chainer-style-transfer python3 ../chainer-fast-neuralstyle/train.py --vggmodel ../chainer-fast-neuralstyle/vgg16.model --dataset dataset/ --style_image style.jpg --output model/style -g 0

    This will generate a new model model/style.model based on style.jpg in a current host working directory. dataset folder also needs to be present there.


Building locally

This step is required only if you want to make modifications to the image and to do a local build.

  • Clone this repo and enter it
    $ git clone https://github.com/jtomori/style_transfer_docker.git
    $ cd style_transfer_docker
  • Build images
    1. neural-fast-style-transfer
      $ docker build -t neural-fast-style-transfer neural-fast-style-transfer
    2. chainer-style-transfer
      $ docker build -t chainer-style-transfer chainer-style-transfer

About

🎨 Docker images with set-up style transfer environments

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published