Git Product home page Git Product logo

adain's Introduction

Repo for implementation of AdaIN in tensorflow-2.0

We have implememted the AdaIN model described in Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization using Tensorflow 2.0 version.

Required environments

  • python 3.7.9
  • tensorflow-gpu 2.4
  • scikit-image 0.18.1
  • kaggle-api: to download dataset from kaggle

The requirements.txt contains all packages in our virtual environment when implementing this model.

Results

Below we presented several examples created by the AdaIN model implemented. The orginal content image is a picture taken in Brown University Main Green. For more examples, please check ./examples/results folder. For pretrained models, click here

Styles Results

Download data

The training content images are MS-COCO and style images are WikiArt. We also provide the preprocessed dataset used in our training. The preprocess includes removing all images that don't have the third dimension, images whose third dimension number is not 3 and images that are too large to raise a warning. All images have been resized to the size of which the shortest dimension is 512. The image ratio is kept during the resizing. Check the clean_images() function in preprocess.py for details.

We provide the cleaned MS-COCO and cleaned WikiArt dataset on google drive. [Click here] We also provide download instruction in the setup.sh. In total, there are 82606 images in cleaned content folder and 78572 images in cleaned style folder.

Usage

Use python run.py --help to check all available arguments. All hyperparameters are included in hyperparameters.py.

Train

python run.py --content-dir ./images/content_cleaned \ 
              --style-dir ./images/style_kaggle_cleaned \ 
              --pretrained-vgg19 ./images/vgg19_normalised.npz

Test

python run.py --load-checkpoint ./output/checkpoints/041921-213116/epoch_1_batch_5000 \
              --evaluate \
              --content-evaluate ./examples/content/brownspring.jpg \
              --style-evaluate ./examples/style/starry_night.jpg

Reference

  1. Repository from Xun Huang, AdaIN-style implemented in Torch, who is the first author of AdaIN model paper
  2. AdaIN-style-transfer---Tensorflow-2.0, implemented in Tensorflow 2.0. (Note: The repo resize all images to (256, 256) without preserving the ratio, which is different from the data preparation described in the paper. It would cause checkboard artifacts in the result.)
  3. Tensorflow-Style-Transfer-with-Adain, implemented in Tensorflow 1.0 version.

adain's People

Contributors

cancan233 avatar sunkworld avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.