ADEM: To Add or Not to Add
Project page (paper and citation) · Code on GitHub
ADEM, the Anticipated Downstream Effect Metric, predicts whether adding a set of new images to a small, correctly labeled training set will improve a model trained on it, without training any model. It scores each candidate image on task relevance, label correctness and uniqueness against the trusted set, and combines them into one signed set-level score: above zero, add the candidate set; at or below zero, don't.
On 1151 candidate sets from 46 image classification, semantic segmentation and object detection tasks, ADEM ranks the candidate sets with a mean Spearman correlation of 0.85 with the gain measured by training, against 0.63 for the strongest of 20 existing metrics, and is the best metric on all 46 tasks.
evaladem is the implementation of ADEM; its code is on GitHub.
Install
pip install evaladem
or, from this repository:
pip install git+https://github.com/caglarmert/ADEM.git
Python 3.9 or newer. The first run downloads the two frozen encoders ADEM uses, CLIP ViT-B/32 and DINOv2 ViT-S/14, from Hugging Face (about 700 MB). A GPU is used when available; the CPU works too, more slowly.
Use
Both folders hold one sub-folder per class; the sub-folder name is the label.
trusted/ candidate/
cat/ 0001.jpg ... cat/ web_17.png ...
dog/ 0002.jpg ... dog/ gen_04.png ...
evaladem --trusted trusted/ --candidate candidate/
For example, on the paper's Oxford-IIIT Pets test bed (370 trusted images, 37 classes) with 500 new, correctly labeled images:
trusted: 370 images, 37 classes (trusted/)
candidate: 500 images, 37 classes (candidate/)
working... (embedding 870 images on cuda)
trusted: 370/370
candidate: 500/500
ADEM = +0.7498 -> add the candidate set
worth 423.0 new, correctly labeled images; 1.1 expected wrong labels (share of correct labels 100%); 1% task-irrelevant
cleaned pool: the 494 of 500 candidate images with phi(d) > 0 -> evaladem_output/cleaned_pool
per-image scores -> evaladem_output/scores.csv; set score and settings -> evaladem_output/summary.json
The same 500 images with half of their labels wrong score −0.3025 (do not add), and a copy of the trusted set −0.0008.
Output folder (--output, default evaladem_output):
| file | content |
|---|---|
cleaned_pool/<class>/... |
copies of the candidate images with image utility φ(d) > 0, the images ADEM expects to help (skip with --no-pool) |
scores.csv |
per candidate image: task relevance r, label correctness q, uniqueness u and utility φ |
summary.json |
the set score and its parts, the settings and the values fitted on the trusted set |
Other options: --device cuda|cpu, --batch N, --overwrite (write into a non-empty output folder, replacing an
earlier run's results).
Reading the score
- ADEM > 0: adding the candidate set is expected to improve the model; ADEM ≤ 0: it is not. The score is signed and has a meaningful zero (an exact copy of the trusted set scores about zero), but it is not a probability or a percentage. Its ranking of candidate sets is more reliable than its zero point.
- φ(d) is in units of one new, correctly labeled image: about +1 for a new, correctly labeled, task-relevant image, 0 for a copy of a trusted image, about −3 for a wrong label and −0.5 for a task-irrelevant image.
- Candidate classes that the trusted set does not have count as wrong labels.
Python
from evaladem import evaluate
r = evaluate("trusted/", "candidate/", output="evaladem_output")
r["adem"], r["add"], r["images"][0] # set score, decision, per-image scores
from evaladem import ADEM, represent # on your own uint8 images (n, W, W, 3) and labels
m = ADEM().fit(represent(x_trusted), y_trusted)
m.set_score(represent(x_candidate), y_candidate)["adem"]
m.image_scores(represent(x_candidate), y_candidate)["phi"]
What it computes
Each image is centre-cropped to a square (and resized to at most 448 px), embedded by CLIP ViT-B/32 and DINOv2 ViT-S/14 on the image as it is and through a Gaussian low-pass filter (standard deviation W/32), and the four unit embeddings are concatenated. Against the trusted set T alone, each candidate image d gets
- r(d), task relevance: its mean similarity to its k = 10 nearest trusted images, ranked among the trusted images' own leave-one-out values (a conformal p-value p), r = min(1, p / 0.05);
- q(d), label correctness: a logistic-regression probe on T's low-pass embeddings (regularisation and temperature by cross-validation on T, T's class prior removed), combined with the share of correct labels of the candidate set, estimated by expectation-maximisation;
- u(d), uniqueness: the part of d not covered by T, shared among its near-copies in the candidate set;
and the utility φ(d) = r q u − 3 r (1 − q) − ½ (1 − r). The set score averages over the classes log(1 + Φc,1 / NcT) − (Φc,2 + Φc,3) / (NcT + NcD), where the Φ are the three parts of φ summed over the candidate images of class c. The settings k = 10, α = 0.05, θ = 3, µ = ½ and the quarter in h are fixed, as in the paper; everything else (the probe, its regularisation and temperature, the reference values of task relevance, h and T's own share of correct labels) is computed from T alone.
Requirements of the trusted set
At least two classes and at least two images per class; it should be correctly labeled and drawn like the data the model will be tested on. For segmentation or detection data, put each image in the folder of its primary class, as the paper does: the majority pixel class (background excluded on object-centric data) or the majority box class.
Citation
The paper and its BibTeX entry are on the project page.
License
evaladem is released under the MIT License (see LICENSE).
The encoder weights are not part of this package: they are downloaded from Hugging Face at first use and are covered
by their own licenses, CLIP ViT-B/32 (openai/clip-vit-base-patch32, OpenAI, MIT License) and DINOv2 ViT-S/14
(facebook/dinov2-small, Meta, Apache License 2.0).
Metadata
Release files for evaladem 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| evaladem-0.1.0.tar.gz | 18.0 kB | Without provenance | Details for evaladem-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| evaladem-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for evaladem-0.1.0-py3-none-any.whl |
Total release size: 34.8 kB
Release files / evaladem-0.1.0.tar.gz
| Download URL | evaladem-0.1.0.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5043721581090084c039104cc11fdee8accb9d95e65630c3881258e35c6009fc
|
|
BLAKE2b-256 checksum How to use checksums |
0ed70a36a174b2a4332c48ce4c0342fc50ba1d5f21b9a3ccc3f6974191382661
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Release files / evaladem-0.1.0-py3-none-any.whl
| Download URL | evaladem-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
315dca06d69cc6abe4482b0b831005d17c944f065e63b83b2cdfe2991598ae41
|
|
BLAKE2b-256 checksum How to use checksums |
dcfa5e718162de754585a76715ae7c02d987e8050bd3795ed2c75bd2a005dc6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Security for evaladem 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.