PyTorch code for our paper: "Color Visual Illusions: A Statistics-based Computational Model", NeurIPS 2020
Preprint version on ArXiv.
Install Requirements
pip3 install -r requirements.txt
Prepare your data
Download an external dataset, i.e. Places.
This implementation uses torchvision.datasets.ImageFolder
. Therefore, the images should be arranged as follows:
+-- <dataset_folder>
| +-- <class_folder>
| | +-- *.png
| +-- <class_folder>
| | +-- *.png
Training
- Prepare a profile file (such as
profile/patch16.json
) - Run the training script:
python train.py [profile]
You can download a pretrained model from here.
Generate Likelihood Graphs
- Make a folder with a sequence of input images (structure of
torchvision.datasets.ImageFolder
) - Prepare a profile file (such as
profile/patch16_graph.json
) - Run the script:
python image_patch_graph.py [profile] --output_path <output_folder> --var_name <X label, i.e. Hue>
Generate Likelihood Heatmap
- Prepare a profile file (such as
profile/patch16_heatmap.json
) - Run the script:
python image_heatmap.py [profile] --output_path <output_folder>
Manipulate Images
- Generate a mask for your image (it should have the same name as the image but located in another folder).
- Prepare a profile file (such as
profile/patch16_manipulation.json
) - Run the script:
python image_heatmap.py [profile] --output_path <output_folder> --mask_folder <mask_folder>
We hope you find our work helpful for your research.
If you are using our code, please consider citing our paper.
@article{hirsch2020color,
title={Color Visual Illusions: A Statistics-based Computational Model},
author={Hirsch, Elad and Tal, Ayellet},
journal={Advances in Neural Information Processing Systems},
volume={33},
year={2020}
}
This project uses source files of corenel/pytorch-glow.
We also acknowledge the official repository of Glow, by OpenAI.