• Stars
    star
    153
  • Rank 241,704 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created over 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A script that applies the AdaIN style transfer method to arbitrary datasets

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

  • Dependencies:

    • python >= 3.6
    • Pillow
    • torch
    • torchvision
    • tqdm
  • Download the models:

  • To stylize a dataset, run python stylize.py.

    Arguments:

    • --content-dir <CONTENT> the top-level directory of the content image dataset (mandatory)
    • --style-dir <STLYE> the top-level directory of the style images (mandatory)
    • --output-dir <OUTPUT> the directory where the stylized dataset will be stored (optional, default: output/)
    • --num-styles <N> number of stylizations to create for each content image (optional, default: 1)
    • --alpha <A> Weight that controls the strength of stylization, should be between 0 and 1 (optional, default: 1)
    • --extensions <EX0> <EX1> ... list of image extensions to scan style and content directory for (optional, default: png, jpeg, jpg). Note: this is case sensitive, --extensions jpg will not scan for files ending on .JPG. Image types must be compatible with PIL's Image.open() (Documentation)
    • --content-size <N> Minimum size for content images, resulting in scaling of the shorter side of the content image to N (optional, default: 0). Set this to 0 to keep the original image dimensions.
    • --style-size <N> Minimum size for style images, resulting in scaling of the shorter side of the style image to N (optional, default: 512). Set this to 0 to keep the original image dimensions (for large style images, this will result in high (GPU) memory consumption).
    • --crop <N> Size for the center crop applied to the content image in order to create a squared image (optional, default 0). Setting this to 0 will disable the cropping.

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

Citation

If you use this code, please consider citing:

@article{michaelis2019dragon,
  title={Benchmarking Robustness in Object Detection: 
    Autonomous Driving when Winter is Coming},
  author={Michaelis, Claudio and Mitzkus, Benjamin and 
    Geirhos, Robert and Rusak, Evgenia and 
    Bringmann, Oliver and Ecker, Alexander S. and 
    Bethge, Matthias and Brendel, Wieland},
  journal={arXiv preprint arXiv:1907.07484},
  year={2019}
}

More Repositories

1

foolbox

A Python toolbox to create adversarial examples that fool neural networks in PyTorch, TensorFlow, and JAX
Python
2,686
star
2

imagecorruptions

Python package to corrupt arbitrary images.
Python
400
star
3

siamese-mask-rcnn

Siamese Mask R-CNN model for one-shot instance segmentation
Jupyter Notebook
346
star
4

model-vs-human

Benchmark your model on out-of-distribution datasets with carefully collected human comparison data (NeurIPS 2021 Oral)
Python
330
star
5

robust-detection-benchmark

Code, data and benchmark from the paper "Benchmarking Robustness in Object Detection: Autonomous Driving when Winter is Coming" (NeurIPS 2019 ML4AD)
Jupyter Notebook
180
star
6

robustness

Robustness and adaptation of ImageNet scale models. Pre-Release, stay tuned for updates.
Python
125
star
7

openimages2coco

Convert Open Images annotations into MS Coco format to make it a drop in replacement
Jupyter Notebook
111
star
8

slow_disentanglement

Towards Nonlinear Disentanglement in Natural Data with Temporal Sparse Coding
Jupyter Notebook
70
star
9

frequency_determines_performance

Code for the paper: "No Zero-Shot Without Exponential Data: Pretraining Concept Frequency Determines Multimodal Model Performance"
Jupyter Notebook
68
star
10

AnalysisBySynthesis

Adversarially Robust Neural Network on MNIST.
Python
64
star
11

game-of-noise

Trained model weights, training and evaluation code from the paper "A simple way to make neural networks robust against diverse image corruptions"
Python
62
star
12

decompose

Blind source separation based on the probabilistic tensor factorisation framework
Python
43
star
13

adversarial-vision-challenge

NIPS Adversarial Vision Challenge
Python
41
star
14

InDomainGeneralizationBenchmark

Python
32
star
15

robust-vision-benchmark

Robust Vision Benchmark
Python
21
star
16

docker

Information and scripts to run and develop the Bethge Lab Docker containers
Makefile
20
star
17

slurm-monitoring-public

Monitor your high performance infrastructure configured over slurm using TIG stack
Python
17
star
18

google_scholar_crawler

Crawl Google scholar publications and authors
Python
12
star
19

magapi-wrapper

Wrapper around Microsoft Academic Knowledge API to retrieve MAG data
Python
10
star
20

testing_visualizations

Code for the paper " Exemplary Natural Images Explain CNN Activations Better than Feature Visualizations"
Python
10
star
21

DataTypeIdentification

Code for the ICLR'24 paper: "Visual Data-Type Understanding does not emerge from Scaling Vision-Language Models"
10
star
22

docker-deeplearning

Development of new unified docker container (WIP)
Python
9
star
23

CiteME

CiteME is a benchmark designed to test the abilities of language models in finding papers that are cited in scientific texts.
Python
9
star
24

notorious_difficulty_of_comparing_human_and_machine_perception

Code for the three case studies: Closed Contour Detection, Synthetic Visual Reasoning Test, Recognition Gap
Jupyter Notebook
8
star
25

tools

Shell
6
star
26

docker-jupyter-deeplearning

Docker Image with Jupyter for Deep Learning (Caffe, Theano, Lasagne, Keras)
6
star
27

lifelong-benchmarks

Benchmarks introduced in the paper: "Lifelong Benchmarks: Efficient Model Evaluation in an Era of Rapid Progress"
6
star
28

sort-and-search

Code for the paper: "Lifelong Benchmarks: Efficient Model Evaluation in an Era of Rapid Progress"
Python
5
star
29

docker-xserver

Docker Image with Xserver, OpenBLAS and correct user settings
Shell
2
star
30

gym-Atari-SpaceInvaders-V0

Python
1
star
31

bwki-weekly-tasks

BWKI Task of the week
Jupyter Notebook
1
star