Home

Awesome

stylize-datasets

This repository contains code for stylizing arbitrary image datasets using AdaIN. The code is a generalization of Robert Geirhos' Stylized-ImageNet code, which is tailored to stylizing ImageNet. Everything in this repository is based on naoto0804's pytorch-AdaIN implementation.

Given an image dataset, the script creates the specified number of stylized versions of every image while keeping the directory structure and naming scheme intact (usefull for existing data loaders or if directory names include class annotations).

Feel free to open an issue in case there is any question.

Usage

The chosen styles per content image will be saved in a content_style_map.json. This file can be used with the --style-map argument to reproduce a specific dataset or to create an explicit content style mapping manually. Keys and values must be existing file names in the --content-dir and --style-dir respectively.

{ 
    "content_image_1.jpg": ["style_1.jpg"],
    "content_image_2.jpg": ["style_2.jpg", "style_3.jpg"]
}

Here is an example call:

 python3 stylize.py --content-dir '/home/username/stylize-datasets/images/' --style-dir '/home/username/stylize-datasets/train/' --num-styles 10 --content_size 0 --style_size 256