All Projects → snu-mllab → Puzzlemix

snu-mllab / Puzzlemix

Licence: mit
Official PyTorch implementation of "Puzzle Mix: Exploiting Saliency and Local Statistics for Optimal Mixup" (ICML'20)

Projects that are alternatives of or similar to Puzzlemix

Multiclass Semantic Segmentation Camvid
Tensorflow 2 implementation of complete pipeline for multiclass image semantic segmentation using UNet, SegNet and FCN32 architectures on Cambridge-driving Labeled Video Database (CamVid) dataset.
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Reproduce Stock Market Direction Random Forests
Reproduce research from paper "Predicting the direction of stock market prices using random forest"
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Zipline Poloniex
Poloniex bundle for zipline
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Google dopamine live
This is the code for "Google Dopamine (LIVE)" by Siraj Raval on Youtube
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Scipy2018 Jupyterlab Tutorial
Tutorial material and instruction for scipy 2018 jupyterlab tutorial
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Bitcoin Price Prediction Using Lstm
Bitcoin price Prediction ( Time Series ) using LSTM Recurrent neural network
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Sampling Free Epistemic Uncertainty
Code for the ICCV 2019 paper "Sampling-free Epistemic Uncertainty Estimation Using Approximated Variance Propagation"
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
E2e Ml App Pytorch
🚀 An end-to-end ML applications using PyTorch, W&B, FastAPI, Docker, Streamlit and Heroku → https://e2e-ml-app-pytorch.herokuapp.com/ (may take few minutes to spin up occasionally).
Stars: ✭ 68 (+1.49%)
Mutual labels:  jupyter-notebook
P3 implement slam
Landmark Detection and Tracking (SLAM) project for CVND
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Stock2vec
📈 Stock embeddings based on PE context
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Movierecommendation
本项目使用两种算法来实现一个电影推荐系统,一个是CNN,另一个是矩阵分解的协同过滤。
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Fish detection
Fish detection using Open Images Dataset and Tensorflow Object Detection
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Juniperkernel
R Kernel for Jupyter
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Yolov3 Googlecolab
A walk through the code behind setting up YOLOv3 with darknet and training it and processing video on Google Colaboratory
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Lovaszsoftmax
Code for the Lovász-Softmax loss (CVPR 2018)
Stars: ✭ 1,148 (+1613.43%)
Mutual labels:  jupyter-notebook
Recall
介绍推荐系统几种算法的实现,可以作为模版在此基础上修改使用。
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Mas Memory Aware Synapses
Memory Aware Synapses method implementation code
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Covid 19 Dataviz
Simple data visualization on Covid-19 data using Pandas and Google Colaboratory
Stars: ✭ 68 (+1.49%)
Mutual labels:  jupyter-notebook
Data bootcamp
Materials for a course at NYU Stern using Python to study economic and financial data.
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook
Pysabr
SABR model Python implementation
Stars: ✭ 67 (+0%)
Mutual labels:  jupyter-notebook

Puzzle Mix: Exploiting Saliency and Local Statistics for Optimal Mixup

This is the code for the paper "Puzzle Mix: Exploiting Saliency and Local Statistics for Optimal Mixup" accepted at ICML'20 (paper, talk, blog). Some parts of the codes are borrowed from manifold mixup (link).

Puzzle Mix image samples

Citing this Work

@inproceedings{kimICML20,
    title= {Puzzle Mix: Exploiting Saliency and Local Statistics for Optimal Mixup},
    author = {Kim, Jang-Hyun and Choo, Wonho and Song, Hyun Oh},
    booktitle = {International Conference on Machine Learning (ICML)},
    year = {2020}
}

Updates

  • (21.01.04) ImageNet training for 300 epochs are conducted! (Top-1 accuracy: 78.76%, details are at ./cutmix).
  • (20.12.01/ torch 1.7) We built a multi-processing code for graph-cut, which runs on CPUs. As a result, the Puzzle Mix implementation (50s/epoch) is only slower about 1.5 times than Vanilla training (34s/epoch) on CIFAR-100, PreActResNet-18. To use the multi-processing, just simply add --mp [n_procs] in the command.

Requirements

This code has been tested with
python 3.6.8
pytorch 1.1.0
torchvision 0.3.0
gco-wrapper (https://github.com/Borda/pyGCO)

matplotlib 2.1.0
numpy 1.13.3
six 1.12.0

Download Checkpoints and Test

We provide a checkpoint of adversarial Puzzle Mix with PreActResNet18 trained on CIFAR-100. The model has 80.34% clean test accuracy and 42.89% accuracy against FGSM with 8/255 l-infinity epsilon-ball.

CIFAR-100 dataset will be downloaded at [data_path], if the dataset is not exist. To test corruption robusetness, please refer to https://github.com/hendrycks/robustness to download dataset. Note that the corruption dataset should be downloaded at [data_path] with the folder name of Cifar100-C (for CIFAR100) and tiny-imagenet-200-C (for Tiny-ImageNet)

To test the model, run:

cd checkpoint   
python test_robust.py --ckpt preactresnet18 --datapath [data_path]

Also, we provide a jupyter notebook, Visualization.ipynb, by which users can visualize Puzzle Mix results with image samples.

Reproducing the results

Detailed descriptions of arguments are provided in main.py. Below are some of the examples for reproducing the experimental results.

ImageNet

To test with ImageNet, please refer to ./imagenet (for 100 epochs training with apex) or ./cutmix (for 300 epochs training).

CIFAR-100

Dataset will be downloaded at [data_path] and the results will be saved at [save_path]. If you want to run codes without saving results, please set --log_off True.

To reproduce Puzzle Mix with PreActResNet18 for 1200 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.1 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 400 800 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_size 4 --t_eps 0.8

To reproduce Puzzle Mix with PreActResNet18 for 600 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 600 --schedule 350 500 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_size 4 --t_eps 0.8

To reproduce adversarial Puzzle Mix with PreActResNet18 for 1200 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.1 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 400 800 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_size 4 --t_eps 0.8 --adv_p 0.1 --adv_eps 10.0

Below are commands to reproduce baselines.

To reproduce Vanilla with PreActResNet18 for 1200 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.1 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 400 800 --gammas 0.1 0.1 --train vanilla

To reproduce input mixup with PreActResNet18 for 1200 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.1 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 400 800 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0

To reproduce manifold mixup with PreActResNet18 for 1200 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.1 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 400 800 --gammas 0.1 0.1 --train mixup_hidden --mixup_alpha 2.0

To reproduce CutMix with PreActResNet18 for 1200 epochs, run:

python main.py --dataset cifar100 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.1 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 400 800 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --box True

For WRN28_10 with 400 epoch, we need to change --arch wrn28_10, --epochs 400, and --schedule 200 300. For WRN28_10 with 200 epoch, we set --epochs 200, --schedule 120 170, and --learning_rate 0.2.

Tiny-Imagenet-200

Download dataset

The following process is forked from (link).

1.Download the zipped data from https://tiny-imagenet.herokuapp.com/
2.If not already exiting, create a subfolder "data" in root folder "PuzzleMix"
3.Extract the zipped data in folder PuzzleMix/data
4.Run the following script (This will arange the validation data in the format required by the pytorch loader)

python load_data.py

To reproduce Puzzle Mix with PreActResNet18 for 1200 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 600 900 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_eps 0.8 --clean_lam 1

To reproduce Puzzle Mix with PreActResNet18 for 600 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 600 --schedule 300 450 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_eps 0.8 --clean_lam 1

To reproduce adversarial Puzzle Mix with PreActResNet18 for 1200 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 600 900 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_eps 0.8 --adv_p 0.15 --adv_eps 10.0 --clean_lam 1

To reproduce adversarial Puzzle Mix with PreActResNet18 for 600 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 600 --schedule 300 450 --gammas 0.1 0.1 --train mixup --mixup_alpha 1.0 --graph True --n_labels 3 --eta 0.2 --beta 1.2 --gamma 0.5 --neigh_size 4 --transport True --t_eps 0.8 --adv_p 0.15 --adv_eps 10.0 --clean_lam 1

Below are commands to reproduce baselines.

To reproduce Vanilla with PreActResNet18 for 1200 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 600 900 --gammas 0.1 0.1 --train vanilla

To reproduce input mixup with PreActResNet18 for 1200 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 600 900 --gammas 0.1 0.1 --train mixup --mixup_alpha 0.2

To reproduce manifold mixup with PreActResNet18 for 1200 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 600 900 --gammas 0.1 0.1 --train mixup_hidden --mixup_alpha 0.2

To reproduce CutMix with PreActResNet18 for 1200 epochs, run:

python main.py --dataset tiny-imagenet-200 --data_dir [data_path] --root_dir [save_path] --labels_per_class 500 --arch preactresnet18  --learning_rate 0.2 --momentum 0.9 --decay 0.0001 --epochs 1200 --schedule 600 900 --gammas 0.1 0.1 --train mixup --mixup_alpha 0.2 --box True

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].