Awesome
Alias-Free Convnets: Fractional Shift Invariance via Polynomial Activations
Official PyTorch implementation
Requirements
We provide installation instructions for ImageNet classification experiments here, based on ConvNeXt instructions.
Dependency Setup
Create an new conda virtual environment
conda create -n convnext python=3.8 -y
conda activate convnext
Install Pytorch>=1.8.0, torchvision>=0.9.0 following official instructions. For example:
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install timm==0.3.2 tensorboardX six
The results in the paper are produced with torch==1.8.0+cu111 torchvision==0.9.0+cu111 timm==0.3.2
.
Dataset Preparation
Download the ImageNet-1K classification dataset and structure the data as follows:
/path/to/imagenet-1k/
train/
class1/
img1.jpeg
class2/
img2.jpeg
val/
class1/
img3.jpeg
class2/
img4.jpeg
Train models
Original ConvNeXt-Tiny
python -m torch.distributed.launch --nproc_per_node=8 --master_port=1440 main.py \
--model convnext_tiny \
--drop_path 0.1 \
--batch_size 32 --update_freq 16 \
--lr 4e-3 \
--model_ema true --model_ema_eval true \
--data_set IMNET \
--data_path </path/to/imagenet> \
--output_dir </path/to/output/dir> \
--epochs 300 --warmup_epochs 20 \
ConvNeXt-Tiny Baseline (circular convolutions)
python -m torch.distributed.launch --nproc_per_node=8 --master_port=1440 main.py \
--model convnext_afc_tiny \
--blurpool_kwargs "{\"filt_size\": 1, \"scale_l2\":false}" \
--activation gelu \
--normalization_type C \
--drop_path 0.1 \
--batch_size 32 --update_freq 16 \
--lr 4e-3 \
--model_ema true --model_ema_eval true \
--data_set IMNET \
--data_path </path/to/imagenet> \
--output_dir </path/to/output/dir> \
--epochs 300 --warmup_epochs 20 \
ConvNeXt-Tiny-AFC
python -m torch.distributed.launch --nproc_per_node=8 --master_port=1440 main.py \
--model convnext_afc_tiny \
--drop_path 0.1 \
--blurpool_kwargs "{\"filter_type\": \"ideal\", \"scale_l2\":false}" \
--activation up_poly_per_channel \
--activation_kwargs "{\"in_scale\":7, \"out_scale\":7, \"train_scale\":true}" \
--model_kwargs "{\"stem_mode\":\"activation_residual\", \"stem_activation\": \"lpf_poly_per_channel\"}" \
--stem_activation_kwargs "{\"in_scale\":7, \"out_scale\":7, \"train_scale\":true, \"cutoff\":0.75}" \
--normalization_type CHW2 \
--batch_size 32 --update_freq 16 \
--lr 4e-3 \
--model_ema true --model_ema_eval true \
--data_set IMNET \
--data_path </path/to/imagenet> \
--output_dir </path/to/output/dir> \
--epochs 300 --warmup_epochs 20 \
ConvNeXt-Tiny-APS
python -m torch.distributed.launch --nproc_per_node=8 --master_port=1440 main.py \
--model convnext_aps_tiny \
--drop_path 0.1 \
--blurpool_kwargs "{\"filt_size\": 1}" \
--activation gelu \
--normalization_type C \
--batch_size 32 --update_freq 16 \
--lr 4e-3 \
--model_ema true --model_ema_eval true \
--data_set IMNET \
--data_path </path/to/imagenet> \
--output_dir </path/to/output/dir> \
--epochs 300 --warmup_epochs 20 \
Checkpoints
Trained models can be Found in: https://huggingface.co/hmichaeli/convnext-afc
Acknowledgement
This repository is built using Truly shift invariant CNNs and ConvNeXt repositories.
-
Truly shift invariant CNNs:
-
ConvNeXt
Citation
If you find this repository helpful, please consider citing:
@InProceedings{Michaeli_2023_CVPR,
author = {Michaeli, Hagay and Michaeli, Tomer and Soudry, Daniel},
title = {Alias-Free Convnets: Fractional Shift Invariance via Polynomial Activations},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2023},
pages = {16333-16342}
}