AffNet
CNN-based affine shape estimator implemented in PyTorch for learning discriminative affine regions via discriminability, as presented at ECCV 2018.
At a Glance
Freely available under the MIT License. Clone, use, modify, and distribute at no cost.
Engagement
Available On
Alternatives
Listed Sep 2026
About AffNet
AffNet is a CNN-based affine shape estimator implemented in PyTorch, released alongside the ECCV 2018 paper "Repeatability Is Not Enough: Learning Discriminative Affine Regions via Discriminability" by Dmytro Mishkin, Filip Radenovic, and Jiri Matas. The project provides code, pre-trained weights, and usage examples for estimating affine shapes of local image features, and is available under the MIT License on GitHub.
What It Is
AffNet is a deep learning model that learns to estimate the affine shape of local image regions, replacing classical iterative methods like Baumberg iterations with a neural network approach. It is designed to work alongside local feature detectors (such as Hessian-Affine) and descriptors (such as HardNet++) to improve image matching and retrieval performance. The core contribution is training the network for discriminability rather than repeatability alone, which the authors argue leads to better correspondences in practice.
Performance on Image Retrieval
The repository benchmarks AffNet against classical baselines on the Oxford5k dataset using mean Average Precision (mAP). According to the README, combining HesAffNet with HardNet++ achieves mAP scores of 68.3 (BoW), 77.8 (BoW + SV), 89.0 (BoW + SV + QE), and 89.5 (HQE + MA), outperforming HesAff + RootSIFT and HesAff + HardNet++ across all evaluation settings. The README also states that AffNet generates up to twice more correspondences compared to Baumberg iterations.
Architecture and Usage
AffNet is a convolutional neural network trained in PyTorch. The repository includes:
- Pre-trained model weights (
AffNet.pth) in thepretrainedfolder - Example scripts for estimating affine shape on patch-column files in HPatches format
- A PyTorch implementation of Hessian-Affine using AffNet for region detection
- Jupyter notebooks for reproducing paper figures and a WBS (Wide Baseline Stereo) demo
- Output in Oxford affine format compatible with standard benchmarks
The input/output interface supports grayscale patch images and produces affine frame parameters (a11, a21, a22) or Oxford affine ellipse format.
Update: PyTorch 1.4 Branch
The master branch corresponds to the original ECCV paper results, targeting Python 2.7 and PyTorch 0.4.0. A separate branch (pytorch1-4_python3) is available for users running Python 3.7 and PyTorch 1.4.0, making the codebase accessible on more modern environments. The repository was last pushed to in April 2025, indicating ongoing maintenance activity.
Audience and Deployment
AffNet targets computer vision researchers and practitioners working on image matching, image retrieval, and local feature pipelines. It is deployed as source code cloned from GitHub, with a shell script (run_me.sh) to download datasets and begin training. The project is cited in academic work and is intended for use as a component within larger feature extraction and matching pipelines.
Community Discussions
Be the first to start a conversation about AffNet
Share your experience with AffNet, ask questions, or help others learn from your insights.
Pricing
Open Source
Freely available under the MIT License. Clone, use, modify, and distribute at no cost.
- Full source code access
- Pre-trained model weights
- Training scripts
- Usage examples and notebooks
- MIT License
Capabilities
Key Features
- CNN-based affine shape estimation
- Pre-trained AffNet.pth model weights
- PyTorch implementation of Hessian-Affine detector
- HPatches format patch input support
- Oxford affine ellipse format output
- Jupyter notebook examples for paper figure reproduction
- WBS (Wide Baseline Stereo) demo notebook
- Comparison with Baumberg iterations
- Dataset download and training scripts
- Python 3.7 / PyTorch 1.4 compatible branch
