Catalog PyPI
PACKAGE EXPLORERView in registry

adapter-plus

PyPI

Adapter+ implementation for vision transformer backbones from timm

Versions collected1
Direct dependencies2From release 0.1.0
Last observed20 Oct, 19:05 UTC

README

Version 0.1.0 documentation

Adapters Strike Back

License Framework

This is the official repository of our paper:

Adapters Strike Back
Jan-Martin O. Steitz and Stefan Roth
CVPR, 2024

Abstract: Adapters provide an efficient and lightweight mechanism for adapting trained transformer models to a variety of different tasks. However, they have often been found to be outperformed by other adaptation mechanisms, including low-rank adaptation. In this paper, we provide an in-depth study of adapters, their internal structure, as well as various implementation choices. We uncover pitfalls for using adapters and suggest a concrete, improved adapter architecture, called Adapter+, that not only outperforms previous adapter implementations but surpasses a number of other, more complex adaptation mechanisms in several challenging settings. Despite this, our suggested adapter is highly robust and, unlike previous work, requires little to no manual intervention when addressing a novel scenario. Adapter+ reaches state-of-the-art average accuracy on the VTAB benchmark, even without a per-task hyperparameter optimization.

Training and evaluation

Install requirements

conda env create -f environment.yml
conda activate adapter_plus

Dataset preparation

For dataset preparation of the VTAB and FGVC benchmarks, please follow VPT. Our configuration expects the VTAB and FGVC dataset folders to reside under datasets/vtab and datasets/fgvc, respectively.

Training

For training, you can select one of the preconfigured experiments from conf/experiments to train on the complete VTAB or FGVC benchmarks or define your own and run for example

python train.py +experiment=vtab/adapter_plus_dim1-32

Results aggregation

To aggregate the results of the VTAB and FGVC benchmarks, you can use the Jupyter notebook get_results.ipynb.

Evaluation of checkpoints

To evaluate checkpoints from previous training runs, use eval.py in combination with the experiment configuration you want to re-evaluate, e.g.:

python eval.py +experiment=vtab/adapter_plus_dim1-32

Disclaimer

Training and evaluation for the paper were done with timm 0.6.7, pytorch 1.12, and python 3.9. For the best possible usability of our pip module, we have updated the code to the latest versions. As such, the numbers on VTAB may vary slightly (we measured up to +/- 0.2 p.p. in accuracy). However, the global average accuracy across all VTAB subgroups remains unchanged.

Use Adapter+ in your own project

To use our adapter implementation in your own project simply, install the pip module:

pip install adapter-plus

Besides various adapter configurations, our module also supports LoRA (without weight matrices merging for inference) and VPT-deep (without checkpointing). Please refer to the configurations in the repository's conf directory for details. Our pip module patches the _create_vision_transformer function of the timm library to support adapters. All vision transformers built with Block or ResPostBlock block functions are supported.

You can create an adapter-enabled vision transformer model as shown below:

import timm
import adapter_plus
from omegaconf import OmegaConf

# create config for Adapter+
# change bottleneck dim as required
adapterplus_conf = OmegaConf.create(
    """
    config: post
    act_layer: true
    norm_layer: false
    bias: true
    init: houlsby
    scaling: channel
    dim: 8
    attn_adapter: false
    dropout: 0
    drop_path: 0.1
    """
)

# create pre-trained timm ViT model 
# with adapter=True and adapter_config
model = timm.create_model(
    "vit_base_patch16_224.orig_in21k",
    adapter=True,
    pretrained=True,
    drop_path_rate=0.1,
    num_classes=101,
    adapter_config=adapterplus_conf,
)

# only require gradients for
# adapters and classifier head
model.requires_grad_(False)
model.head.requires_grad_(True)
for m in model.modules():
    if isinstance(m, adapter_plus.Adapter):
        m.requires_grad_(True)

Acknowledgements

This work has been funded by the LOEWE initiative (Hesse, Germany) within the emergenCITY center.

Citation

@inproceedings{Steitz:2024:ASB,
  author    = {Steitz, Jan-Martin O. and Roth, Stefan},
  title     = {Adapters Strike Back},
  booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  month     = {June},
  year      = {2024},
  pages     = {23449--23459}
}

Downloads & popularity

2downloads
1-day window · source-reported counts18 Oct 2026
94.50
2026-07-23: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-07-23–2026-07-232026-07-27: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-07-27–2026-07-272026-08-01: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-01–2026-08-012026-08-02: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-02–2026-08-022026-08-03: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-03–2026-08-032026-08-04: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-04–2026-08-042026-08-09: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-09–2026-08-092026-08-11: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-11–2026-08-112026-08-13: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-13–2026-08-132026-08-14: 4 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-14–2026-08-142026-08-16: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-16–2026-08-162026-08-17: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-17–2026-08-172026-08-20: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-20–2026-08-202026-08-22: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-22–2026-08-222026-08-23: 3 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-23–2026-08-232026-08-24: 9 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-24–2026-08-242026-08-25: 3 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-25–2026-08-252026-08-28: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-28–2026-08-282026-08-31: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-08-31–2026-08-312026-09-03: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-03–2026-09-032026-09-07: 4 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-07–2026-09-072026-09-09: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-09–2026-09-092026-09-12: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-12–2026-09-122026-09-13: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-13–2026-09-132026-09-22: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-22–2026-09-222026-09-24: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-24–2026-09-242026-09-25: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-25–2026-09-252026-09-26: 3 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-26–2026-09-262026-09-27: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-27–2026-09-272026-09-28: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-28–2026-09-282026-09-29: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-29–2026-09-292026-09-30: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-09-30–2026-09-302026-10-06: 1 · observed 2026-10-20T19:23:57.4787604Z · period 2026-10-06–2026-10-062026-10-09: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-10-09–2026-10-092026-10-13: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-10-13–2026-10-132026-10-18: 2 · observed 2026-10-20T19:23:57.4787604Z · period 2026-10-18–2026-10-18
23 Jul18 Oct

pypistats · 36 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-18 – 2026-10-1822026-10-20T19:23:57.4787604Z
2026-10-13 – 2026-10-1322026-10-20T19:23:57.4787604Z
2026-10-09 – 2026-10-0922026-10-20T19:23:57.4787604Z
2026-10-06 – 2026-10-0612026-10-20T19:23:57.4787604Z
2026-09-30 – 2026-09-3012026-10-20T19:23:57.4787604Z
2026-09-29 – 2026-09-2912026-10-20T19:23:57.4787604Z
2026-09-28 – 2026-09-2822026-10-20T19:23:57.4787604Z
2026-09-27 – 2026-09-2712026-10-20T19:23:57.4787604Z
2026-09-26 – 2026-09-2632026-10-20T19:23:57.4787604Z
2026-09-25 – 2026-09-2512026-10-20T19:23:57.4787604Z
2026-09-24 – 2026-09-2412026-10-20T19:23:57.4787604Z
2026-09-22 – 2026-09-2212026-10-20T19:23:57.4787604Z
2026-09-13 – 2026-09-1312026-10-20T19:23:57.4787604Z
2026-09-12 – 2026-09-1212026-10-20T19:23:57.4787604Z
2026-09-09 – 2026-09-0912026-10-20T19:23:57.4787604Z
2026-09-07 – 2026-09-0742026-10-20T19:23:57.4787604Z
2026-09-03 – 2026-09-0312026-10-20T19:23:57.4787604Z
2026-08-31 – 2026-08-3122026-10-20T19:23:57.4787604Z
2026-08-28 – 2026-08-2812026-10-20T19:23:57.4787604Z
2026-08-25 – 2026-08-2532026-10-20T19:23:57.4787604Z
2026-08-24 – 2026-08-2492026-10-20T19:23:57.4787604Z
2026-08-23 – 2026-08-2332026-10-20T19:23:57.4787604Z
2026-08-22 – 2026-08-2212026-10-20T19:23:57.4787604Z
2026-08-20 – 2026-08-2012026-10-20T19:23:57.4787604Z
2026-08-17 – 2026-08-1722026-10-20T19:23:57.4787604Z
2026-08-16 – 2026-08-1622026-10-20T19:23:57.4787604Z
2026-08-14 – 2026-08-1442026-10-20T19:23:57.4787604Z
2026-08-13 – 2026-08-1322026-10-20T19:23:57.4787604Z
2026-08-11 – 2026-08-1122026-10-20T19:23:57.4787604Z
2026-08-09 – 2026-08-0912026-10-20T19:23:57.4787604Z
2026-08-04 – 2026-08-0412026-10-20T19:23:57.4787604Z
2026-08-03 – 2026-08-0322026-10-20T19:23:57.4787604Z
2026-08-02 – 2026-08-0212026-10-20T19:23:57.4787604Z
2026-08-01 – 2026-08-0112026-10-20T19:23:57.4787604Z
2026-07-27 – 2026-07-2712026-10-20T19:23:57.4787604Z
2026-07-23 – 2026-07-2322026-10-20T19:23:57.4787604Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.023 Jul 20242

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
visinf/adapter_plus

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:05 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:2177b45e1e0864157d6e9fdf7560a5178d27a78fd6724d8c2191161bff328aab