This repository contains examples of anti-aliased convnets.
Table of contents
- Pretrained antialiased models
- Instructions for antialiasing your own model, using the
- Results on Imagenet consistency + accuracy.
- ImageNet training and evaluation code. Achieving better consistency, while maintaining or improving accuracy, is an open problem. Help improve the results!
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
All material is made available under Creative Commons BY-NC-SA 4.0 license by Adobe Inc. You can use, redistribute, and adapt the material for non-commercial purposes, as long as you give appropriate credit by citing our paper and indicating any changes that you've made.
(0) Getting started
- Install PyTorch (pytorch.org)
pip install -r requirements.txt
Download anti-aliased models
(1) Quickstart: load an antialiased model
The following loads a pretrained antialiased model, perhaps as a backbone for your application.
import torch import models_lpf.resnet model = models_lpf.resnet.resnet50(filter_size=3) model.load_state_dict(torch.load('weights/resnet50_lpf3.pth.tar')['state_dict'])
We also provide weights for antialiased
MobileNetv2 (see example_usage.py).
(2) Antialias your own architecture
The methodology is simple -- first evaluate with stride 1, and then use our
Downsample layer (also referred to as
BlurPool) to do antialiased downsampling.
models_lpfinto your codebase, which contains the
Downsampleclass, which does blur+subsampling. Put the following into your header.
from models_lpf import *
- Make the following architectural changes to antialias your strided layers. Typically, blur kernel
Mis 3 or 5.
We assume incoming tensor has
C channels. Computing a layer at stride 1 instead of stride 2 adds memory and run-time. As such, we typically skip antialiasing at the highest-resolution (early in the network), to prevent large increases.
We show consistency (y-axis) vs accuracy (x-axis) for various networks. Up and to the right is good. Training and testing instructions are here.
We italicize a variant if it is not on the Pareto front -- that is, it is strictly dominated in both aspects by another variant. We bold a variant if it is on the Pareto front. We bold highest values per column.
Antialiasing requires extra computation (but no extra parameters). Below, we measure run-time (x-axis, both plots) on a forward pass of batch of 48 images of 224x224 resolution on a RTX 2080 Ti. In this case, gains in accuracy (y-axis, left) and consistency (y-axis, right) end up justifying the increased computation.
(4) Training and Evaluation
To reduce clutter, this is linked here. Help improve the results!
(B) Citation, Contact
If you find this useful for your research, please consider citing this bibtex. Please contact Richard Zhang <rizhang at adobe dot com> with any comments or feedback.