TGraphX › Insights › Visual Similarity Search: Finding and Annotating Objects from One Example
← Back to Insights

Visual Similarity Search: Finding and Annotating Objects from One Example

Topic: Vision, multimodal and domain applications

Visual similarity search takes one example, such as a box drawn around a bolt, and looks for other places that resemble it. Inside a single image this means comparing the example's features with the features at every position of the target, turning the result into a similarity map, and picking the peaks. It needs no training run and no class list.

It also returns exactly what the name says: similar regions. Not "the same object", not "the same class". The experiment below shows a second copy of the same drawing scoring less than 1, a recoloured version scoring almost as high as the copy, and an object with a piece missing passing a plausible threshold.

Three tasks that look alike

Task Question Unit compared Output
Image retrieval Which images are like this one? One vector per image Ranked list of images
Object detection Where are instances of these classes? Learned class head Boxes with class and score
Region similarity Where does something like this crop appear? Patches or windows against an example Positions or boxes in the target, with similarity scores

Retrieval can say that two photographs both show a workbench full of fasteners without telling you where any of them is. A detector can locate "bolt" only if it was trained for it. Region similarity sits in between: it localises, from one example, without knowing a name.

From pixels to a grid of descriptors

A vision transformer cuts an image into square patches, 14 by 14 pixels for DINOv2, and produces one vector for each. A 560 by 336 input therefore gives a grid of 24 rows by 40 columns of descriptors, each with 384 numbers for the small model, plus one class token that summarises the whole image.

That grid is the dense feature map. DINOv2 and DINOv3 are trained without labels, and their patch descriptors tend to be alike for parts that look alike or play a similar role. Two properties are easy to forget:

  • A patch descriptor is not a description of those 196 pixels alone. Through attention it also depends on the rest of the input and on its position.
  • The grid is coarse. An object smaller than a patch shares its descriptor with whatever surrounds it.

How many patches does your object cover?

Check this before anything else. If an image of width W pixels is resized to width W_in for the model, an object w pixels wide covers

patches = w * (W_in / W) / 14

patches along that side. For a 60 pixel object in a 4000 pixel wide photograph:

Processing Object width at the model Patches along that side
Whole image resized to 518 60 × 518 / 4000 = 7.8 px 0.55
Whole image resized to 1036 15.5 px 1.1
448 px tile fed at 448 (no resize) 60 px 4.3
224 px tile upscaled to 448 120 px 8.6

Below one patch there is nothing to match. Cutting the image into overlapping tiles restores resolution at the price of more forward passes, and it limits what each patch can see of its surroundings, so scores near tile borders and across tile sizes need care.

Normalisation, dot product and cosine

For two feature vectors a and b with d components:

cos(a, b) = dot(a, b) / (norm(a) * norm(b))

where dot(a, b) is the sum of the products of matching components and norm(a) is the square root of dot(a, a). If every descriptor is first divided by its own norm (L2 normalisation), the dot product is the cosine, so a similarity map is one matrix multiplication. For unit vectors, squared Euclidean distance is 2 - 2 * cos(a, b), so ranking by distance and ranking by cosine give the same order.

Cosine ignores length and keeps direction. Edit the vectors below and note that doubling one of them changes the dot product but not the cosine.

Cosine similarity of two small descriptors

A table of two four component vectors with their products, unit length versions, dot product, norms and cosine similarity, showing that cosine depends on direction rather than length.

Edit any vector component in the table.

a = example patch, b = target patch. cosine(a, b) = a·b / (‖a‖ ‖b‖)

Components, products and unit length versions
kaba×ba/‖a‖b/‖b‖
060.6670.775
110.3330.258
200.0000.258
340.6670.516
dot product a·b
11
norm ‖a‖
3.0000
norm ‖b‖
3.8730
cosine similarity
0.9467

Dot product 11, norms 3.0000 and 3.8730: cosine similarity 0.9467.

Edit any component. Scaling a whole vector leaves the cosine unchanged, while changing its direction does not. Exact arithmetic on hand-chosen vectors, printed with at most four decimals. They are illustrative, not embeddings from a model, and no score here is a decision threshold.

Turning one example into a similarity map

Let f(p) be the unit descriptor of target position p, and let the example crop cover the descriptors e(1) to e(n). Three common constructions:

  1. Mean descriptor. Average the example's descriptors, renormalise to get m, and score each position with S(p) = dot(m, f(p)). Compact and tolerant of layout changes, but any background inside the crop is averaged in.
  2. Template matching. Keep the example's grid and slide it: S(o) = (1/n) * sum over cells c of dot(e(c), f(o + c)) for each placement o. Layout counts, so a rearranged or rotated object scores lower.
  3. Nearest neighbours. Match each target patch to its most similar example patch, optionally requiring that the match also works backwards, from the reference image into the example region.

From a reference crop to reviewed candidates

Reference cropExampledescriptorsSimilarity mapNormalise andthresholdPeaks, overlapremovalReview candidatesTarget imageDense feature map
The same diagram as a table
boxarrows to
Reference cropExample descriptors
Example descriptorsSimilarity map
Similarity mapNormalise and threshold
Normalise and thresholdPeaks, overlap removal
Peaks, overlap removalReview candidates
Review candidates—
Target imageDense feature map
Dense feature mapSimilarity map

8 boxes and 7 arrows. No box is selected.

Follow the two inputs into one similarity map, then the steps that turn numbers into boxes a person can check. A schematic drawn from the author's description: nothing is executed or measured.

From a map to candidates

A raw cosine has no natural cut-off. In one image the whole background may sit near 0.3, in another near 0.7. One remedy is to rescale each image's scores between its own typical value and the example's score against itself:

r = clip((s - median) / (s_self - median), 0, 1)

Here s is a position's score, median is the middle score over the target image, s_self is the example compared with itself, and clip limits the result to the range 0 to 1. With invented numbers:

Raw score s Image median Self score Relative score r
0.80 0.30 0.95 0.50 / 0.65 = 0.769
0.80 0.70 0.95 0.10 / 0.25 = 0.400

The same cosine means different things in the two images. The rescaled value is not a probability either, and since the median depends on what else is in the picture, it is not comparable across images.

After thresholding, keep local maxima, discard boxes that overlap a stronger one beyond a chosen intersection over union (non-maximum suppression), exclude the reference itself, or group neighbouring positions into regions if you want shapes rather than fixed-size boxes.

Experiment: a scene with known distractors

To see what the scores do, draw a scene where the answer is known. The reference is a dark ring with a red cross, 84 pixels (6 by 6 patches). The scene also holds an identical copy, a blue cross, a version rotated by 45 degrees, a ring with no cross, a cross with no ring, a square frame and a 60 percent copy. The drawings have gaps, so the background shows through them. The same scene is built twice, on light noise and with random clutter behind it.

Environment of the recorded output: Python 3.13.12, PyTorch 2.15.0, transformers 5.24.1, Pillow 13.0.0, NumPy 2.5.5, facebook/dinov2-small at the pinned revision, one NVIDIA GeForce RTX 5080, run on 2026-11-27.

python
import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image, ImageDraw
from transformers import AutoModel

MODEL, REVISION = "facebook/dinov2-small", "ed25f3a31f01632728cabb09d1542f84ab7b0056"
PATCH = 14
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModel.from_pretrained(MODEL, revision=REVISION).to(device).eval()
MEAN = torch.tensor([0.485, 0.456, 0.406]).view(3, 1, 1)
STD = torch.tensor([0.229, 0.224, 0.225]).view(3, 1, 1)


def patch_features(image):
    """Unit patch descriptors [rows, cols, 384] of an image whose sides are multiples of 14."""
    pixels = torch.from_numpy(np.asarray(image, np.float32) / 255).permute(2, 0, 1)
    pixels = ((pixels - MEAN) / STD)[None].to(device)
    with torch.inference_mode():
        tokens = model(pixel_values=pixels).last_hidden_state[0, 1:]      # drop the class token
    return F.normalize(tokens, dim=-1).reshape(image.height // PATCH, image.width // PATCH, -1).cpu()


def sprite(ring=True, cross=True, color=(200, 40, 40), angle=0, square=False, size=84):
    s = 336                                    # draw large, then shrink for smooth edges
    image = Image.new("RGBA", (s, s), (0, 0, 0, 0))
    draw = ImageDraw.Draw(image)
    if ring:
        (draw.rectangle if square else draw.ellipse)([16, 16, s - 16, s - 16], outline=(50, 50, 55, 255), width=44)
    if cross:
        draw.rectangle([s // 2 - 20, 40, s // 2 + 20, s - 40], fill=color + (255,))
        draw.rectangle([40, s // 2 - 20, s - 40, s // 2 + 20], fill=color + (255,))
    return image.rotate(angle, resample=Image.BICUBIC).resize((size, size), Image.LANCZOS)


# name: (column, row, sprite), positions in patch units
OBJECTS = {"reference": (2, 2, sprite()), "identical copy": (11, 2, sprite()),
           "blue cross": (20, 2, sprite(color=(40, 70, 200))), "rotated 45": (29, 2, sprite(angle=45)),
           "ring, no cross": (2, 13, sprite(cross=False)), "cross, no ring": (11, 13, sprite(ring=False)),
           "square frame": (20, 13, sprite(square=True)), "60% size": (30, 14, sprite(size=50))}


def scene(clutter=False):
    noise = np.random.default_rng(0).normal(205, 8, (336, 560, 1)).repeat(3, axis=2)
    image = Image.fromarray(np.clip(noise, 0, 255).astype(np.uint8))
    if clutter:
        rng, draw = np.random.default_rng(1), ImageDraw.Draw(image)
        for _ in range(500):
            x, y = int(rng.integers(0, 540)), int(rng.integers(0, 320))
            w, h = int(rng.integers(6, 24)), int(rng.integers(6, 24))
            color = tuple(int(v) for v in rng.integers(40, 230, 3))
            shape = draw.ellipse if rng.random() < 0.5 else draw.rectangle
            shape([x, y, x + w, y + h], outline=color, width=3)
    for column, row, item in OBJECTS.values():
        image.paste(item, (column * PATCH, row * PATCH), item)
    return image


def template_map(features, template):
    """Mean cell-by-cell cosine of the template at every placement."""
    h, w = template.shape[:2]
    windows = features.unfold(0, h, 1).unfold(1, w, 1)                     # [R, C, 384, h, w]
    return (windows * template.permute(2, 0, 1)).sum(2).mean((-1, -2))


def relative(score, scores, self_score):
    median = scores.median().item()
    return min(1.0, max(0.0, (score - median) / (self_score - median)))


column, row, _ = OBJECTS["reference"]
for clutter in (False, True):
    features = patch_features(scene(clutter))
    scores = template_map(features, features[row:row + 6, column:column + 6])
    print("cluttered" if clutter else "plain", f"background: median placement score {scores.median().item():.3f}")
    for name, (c, r, _) in OBJECTS.items():
        best = scores[max(0, r - 2):r + 3, max(0, c - 2):c + 3].max().item()      # best placement nearby
        print(f"  {name:15s} cosine {best:.3f}  relative {relative(best, scores, scores[row, column].item()):.3f}")
text
plain background: median placement score 0.514
  reference       cosine 1.000  relative 1.000
  identical copy  cosine 0.950  relative 0.898
  blue cross      cosine 0.934  relative 0.864
  rotated 45      cosine 0.863  relative 0.719
  ring, no cross  cosine 0.769  relative 0.524
  cross, no ring  cosine 0.647  relative 0.274
  square frame    cosine 0.677  relative 0.336
  60% size        cosine 0.610  relative 0.199
cluttered background: median placement score 0.514
  reference       cosine 1.000  relative 1.000
  identical copy  cosine 0.838  relative 0.666
  blue cross      cosine 0.799  relative 0.586
  rotated 45      cosine 0.781  relative 0.548
  ring, no cross  cosine 0.732  relative 0.449
  cross, no ring  cosine 0.562  relative 0.099
  square frame    cosine 0.603  relative 0.184
  60% size        cosine 0.569  relative 0.113

Reading the numbers:

  • The identical copy does not score 1. The drawing is the same, but the noise showing through its gaps and around it is not, and a descriptor also depends on its position and on the rest of the picture. A threshold near 1 would miss real duplicates.
  • Colour barely counted. On the plain background the blue cross is within 0.02 in cosine of the identical copy. If red and blue handles are different part numbers in your catalogue, similarity will not keep them apart.
  • A missing part passed. On the plain background the empty ring has a relative score above 0.5. It is the high-scoring wrong match: similar outline, wrong object.
  • Scale cost the most, rotation less. The 60 percent copy scores lowest on the plain background; the 45 degree version fell below the blue one. Nothing here searches over scales or angles.
  • The background moved everything. With clutter behind the same objects, the identical copy drops below what the rotated copy scored on the plain background. The median barely changed; the descriptors themselves did, because clutter shows through the gaps of the drawings, including the reference, and patches also see their surroundings.

The same objects score differently on a different background

relative score00.51threshold 0.5refblueringsquareobject

plain background (circles)cluttered (squares, dashed)

plain background, values at or above the threshold: 5 of 8 (ref, copy, blue, rot 45, ring)

cluttered, values at or above the threshold: 4 of 8 (ref, copy, blue, rot 45)

relative score by object
objectplain backgroundclutteredat or above threshold
ref11plain background, cluttered
copy0.8980.666plain background, cluttered
blue0.8640.586plain background, cluttered
rot 450.7190.548plain background, cluttered
ring0.5240.449plain background
cross0.2740.099none
square0.3360.184none
60%0.1990.113none

Threshold 0.5. plain background is at or above it at 5 of 8 (ref, copy, blue, rot 45, ring). cluttered is at or above it at 4 of 8 (ref, copy, blue, rot 45).

Move the threshold and watch which objects are accepted on each background. The copy should be accepted; the empty ring should not. Measured values, as recorded by the author: DINOv2 small template matching on a drawn 560 by 336 scene, transformers 5.24.1, RTX 5080, 2026-11-27. The figure only displays and compares them. Which values cross the threshold is computed from them.

Looking at the map itself

The table of per-object scores hides the shape of the map. Computing the relative score of every placement gives one value for each position where the 6 by 6 template fits:

python
features = patch_features(scene())
scores = template_map(features, features[row:row + 6, column:column + 6])
heat = ((scores - scores.median()) / (1 - scores.median())).clamp(0, 1)    # the reference scores 1 by construction
print(list(heat.shape), int((heat >= 0.5).sum()), "placements reach 0.5")
text
[19, 35] 20 placements reach 0.5

Relative similarity of the reference at every placement

A grid of 19 rows by 35 columns of relative similarity for the plain scene. The brightest cell is the reference at the upper left, with further bright blobs along the top for the copy, the blue and the rotated objects, and a weaker one at lower left for the empty ring.

relative score (cells below the threshold are dimmed)

0 (dark)1 (light)

Left to right: patch column 0 to 34. Top to bottom: patch row 0 to 18.

selected cell
patch row 0, patch column 0
relative score there
0.144
relative score: cells counted
20 of 665
relative score: patch row (rows) by patch column (columns)
row012345678910111213141516171819202122232425262728293031323334
00.1440.2110.2460.2450.1480.1430.1750.1510.1210.1080.190.2020.1950.1440.1070.1440.090.0520.070.1410.1890.170.1050.1020.1410.1240.1030.1070.1560.1690.1230.08000
10.2580.440.5820.4770.2790.2270.2510.2380.2270.2620.4430.5560.4310.2660.1730.20.1730.1470.1930.3790.530.3830.2230.1810.220.1950.1610.2190.3760.4730.330.1590.01800
20.2810.6110.650.3590.3120.3750.3580.3230.340.6070.8980.5820.3030.2350.3010.2830.2520.2630.5370.8630.5330.2870.2630.3210.2960.2250.3390.5310.7180.4990.1780.00900
30.2560.4690.6420.520.3350.2410.2890.2670.2340.2880.4630.5780.4720.2890.2110.2620.2350.2190.2320.4170.5590.4170.2580.2050.2650.2440.2070.2860.4330.5160.3640.152000
40.1460.240.2940.2770.1830.1260.1540.1420.0910.1210.1920.2120.2110.1150.0850.1130.1020.0750.0720.180.2190.1870.1030.0660.10.1010.0690.090.170.1920.1490.038000
50.0310.0660.1230.1020.0430.050.0450.040.0230.0080.0370.0920.0810.0060.0190.0290.023000.040.0960.0530.010.0120.008000.0030.01200.0080000
600.0480.0730.070.0530.01900000.0330.0310.0310000000.0360.0480.030.02000000000000
700.0340.10.0550000000000000000.0310.040.0070000000000000
8000.0570.0230000000000000000000000000000000
9000.0050.0030000000000000000000000000000000
10000.0230.0230.0050.0200000000000000000000000000000
110.0590.1160.1390.1330.0860.0980.07500000.0170.00600000.0090.0510.0970.1090.0910.03100.0220.0280.00800.0560.05500000
120.1220.2670.3490.3020.1710.1070.1180.0410.0090.0230.1070.1660.1250.0620.0180.0070.0070.0570.140.2330.2590.2140.1140.0630.040.0550.0380.0620.1840.1380.0350000
130.1470.3590.5240.3820.20.140.1450.1360.0830.0980.2010.2730.2060.130.0840.0680.0560.0950.1840.2890.3350.2750.1530.1010.0670.1040.090.1190.1990.1480.0660000
140.0940.2540.3320.270.1560.0910.10.050.0140.0290.0850.1440.1270.060.0250.0160.0230.0630.1380.2270.2810.2290.1090.0620.0260.035000.0790.0600000
1500.0190.0410.050.011000000000000000.0310.0830.0480000000000000
1600000000000000000000000000000000000
1700000000000000000000000000000000000
1800000000000000000000000000000000000

Cell patch row 0, patch column 0: relative score 0.144 (below the threshold). Cells at or above 0.5: relative score 20 of 665.

Raise the threshold from 0.5 and watch which blobs survive. Each cell is the template position given by its top-left patch. Measured grid values, as recorded by the author: DINOv2 small template matching on the drawn scene, relative score cut to 3 decimals, transformers 5.24.1, 2026-11-27. The figure only displays and compares them. A cell counts when its value is at or above the threshold.

The bright regions are blobs, not single cells: neighbouring placements share most of their patches. That is why candidate selection needs peak picking with overlap removal, or each object would be reported several times.

Whole object or part?

A small crop asks a different question. Here the template is only the 2 by 2 patches at the hub of the reference cross, and each object gets its best placement inside its own footprint:

python
hub = features[row + 2:row + 4, column + 2:column + 4]
scores = template_map(features, hub)
for name, (c, r, item) in OBJECTS.items():
    cells = item.width // PATCH
    best = scores[r:r + cells - 1, c:c + cells - 1].max().item()
    print(f"{name:15s} cosine {best:.3f}  relative {relative(best, scores, scores[row + 2, column + 2].item()):.3f}")
text
reference       cosine 1.000  relative 1.000
identical copy  cosine 0.972  relative 0.959
blue cross      cosine 0.955  relative 0.932
rotated 45      cosine 0.930  relative 0.895
ring, no cross  cosine 0.463  relative 0.198
cross, no ring  cosine 0.869  relative 0.804
square frame    cosine 0.899  relative 0.849
60% size        cosine 0.714  relative 0.573

At a 0.5 threshold the part query accepts everything that has a hub, including the bare cross and the square frame, and rejects the empty ring (0.198). The whole-object query did the reverse for the bare cross and the empty ring: it rejected the cross (0.274) and let the ring through (0.524). Neither is better. They answer different questions.

A whole-object query and a part query on one scene

relative score00.51threshold 0.5refblueringsquareobject

whole object (circles)hub only (squares, dashed)

whole object, values at or above the threshold: 5 of 8 (ref, copy, blue, rot 45, ring)

hub only, values at or above the threshold: 7 of 8 (ref, copy, blue, rot 45, cross, square, 60%)

relative score by object
objectwhole objecthub onlyat or above threshold
ref11whole object, hub only
copy0.8980.959whole object, hub only
blue0.8640.932whole object, hub only
rot 450.7190.895whole object, hub only
ring0.5240.198whole object
cross0.2740.804hub only
square0.3360.849hub only
60%0.1990.573hub only

Threshold 0.5. whole object is at or above it at 5 of 8 (ref, copy, blue, rot 45, ring). hub only is at or above it at 7 of 8 (ref, copy, blue, rot 45, cross, square, 60%).

Compare which objects each query accepts at the same threshold, on the plain background. Measured values, as recorded by the author: DINOv2 small, 6 by 6 versus 2 by 2 patch templates on the same drawn scene, transformers 5.24.1, 2026-11-27. The figure only displays and compares them. Which values cross the threshold is computed from them.
Choice Finds Misses or confuses Use when
Whole-object crop Items with the same overall layout Rotated, resized or occluded items; passes near-complete wrong ones Counting repeated, similarly posed objects
Part or detail crop Anything containing that detail Cannot say which whole object it belongs to Locating a feature such as a screw head or logo
Tight box Less background in the descriptor Very small crops cover few patches Default
Several examples More appearance variation Averaging dissimilar examples blurs the descriptor Objects that vary in pose or lighting

If you want the object that contains the example rather than the example-sized region, you need grouping on top of similarity. INSID3 is one published, training-free method: it takes DINOv3 features, removes a position-dependent component from them for cross-image matching, clusters the target patches and keeps clusters that agree with the reference in both matching directions, producing a segmentation mask.

A real photograph

Drawn shapes are not photographs. The second test uses the CC0 cat photograph distributed with scikit-image (skimage.data.chelsea(), saved as chelsea.png). The example is a box around one eye, pooled into a mean descriptor, and the question is where else it responds.

python
photo = Image.open("chelsea.png").convert("RGB")                 # 451 x 300
sx, sy = 448 / photo.width, 294 / photo.height
features = patch_features(photo.resize((448, 294), Image.BICUBIC))   # 21 x 32 patches


def cells(x1, y1, x2, y2):
    """Patch rows and columns whose centres fall inside a box given in original pixels."""
    rows = [i for i in range(21) if y1 * sy <= i * PATCH + 7 < y2 * sy]
    columns = [j for j in range(32) if x1 * sx <= j * PATCH + 7 < x2 * sx]
    return rows, columns


rows, columns = cells(133, 83, 210, 148)          # the eye on the left of the picture
other_rows, other_columns = cells(294, 108, 347, 166)     # the other eye, used only to score the result
example = F.normalize(features[rows][:, columns].reshape(-1, features.shape[-1]).mean(0), dim=0)
similarity = features @ example
print(f"median {similarity.median().item():.3f}, example's own patches {similarity[rows][:, columns].mean().item():.3f}")

masked = similarity.clone()
masked[rows[0] - 1:rows[-1] + 2, columns[0] - 1:columns[-1] + 2] = -1      # hide the example itself
best = torch.topk(masked.flatten(), 12)
for value, index in zip(best.values.tolist(), best.indices.tolist()):
    i, j = divmod(index, 32)
    where = "other eye" if i in other_rows and j in other_columns else "elsewhere"
    print(f"{value:.3f}  patch row {i:2d} col {j:2d}  {where}")
text
median 0.251, example's own patches 0.876
0.861  patch row 10 col 23  other eye
0.856  patch row  8 col 23  other eye
0.854  patch row 10 col 22  other eye
0.852  patch row  9 col 21  other eye
0.838  patch row 10 col 21  other eye
0.836  patch row  9 col 23  other eye
0.827  patch row 11 col 22  other eye
0.821  patch row  8 col 22  other eye
0.805  patch row  9 col 24  other eye
0.790  patch row  7 col 23  elsewhere
0.742  patch row 11 col 21  other eye
0.722  patch row  9 col 22  other eye

The nine strongest responses outside the example all fall in the other eye, as do eleven of the top twelve, far above the image median. One easy photograph is an illustration of the mechanism, not an accuracy estimate: change the photograph, the box or the model size and measure again.

Similar is not the same instance

A cosine score carries no identity. Two bolts from one batch are, as far as appearance goes, interchangeable, so a high score cannot tell you that this is the bolt you saw before. In the other direction, one individual object can score lower against itself after turning or changing scale, as the drawn objects above did. Keep three claims apart: looks alike (what similarity measures), same class (a labelling decision with rules) and same individual (which needs other evidence such as position over time, a serial mark or a tracker).

Using similarity for annotation

Similarity search is a proposal generator. A sound loop:

  1. Draw a tight example. Check that it covers several patches at the model's input size.
  2. Rank candidates and review them from the top. Accept, adjust or reject each one.
  3. Scan the image for misses: nothing in a candidate list shows what was not found.
  4. Choose any automatic threshold on images you have labelled by hand, and report precision (accepted candidates that are right) and recall (true objects found) there.
  5. Never assign a class from similarity alone where the classes differ by colour, size or a small part.

Two numbers summarise a ranked list on a labelled test image. Precision at k is the share of the top k candidates that are wanted objects. Recall at k is the share of all wanted objects that appear among those k. Report both on images that contain look-alikes, and on at least one image that contains no true instance at all: a ranking has a first entry whether or not the object is there.

The review decisions, and how to measure a correction with IoU and Dice, are covered in AI-assisted image annotation.

To compare whole images instead of regions, for deduplication or retrieval, use one vector per image; and the same cosine over embeddings is a common way to build neighbour graphs, as in the vision graph recipes.

Similarity tools in Anastig

Disclosure: the author of this article is also involved in building Anastig.

Anastig is an independent, early-access visual AI platform, not part of TGraphX (overview on this site). As of 2026-11-27 several different things there involve "similarity", and they should not be merged:

Tool Runs Compares Returns Access
Visual Similarity (DINOv2 Small, Base, Large), Beta This device Patch grids or a mean descriptor Boxes No account
INSID3 with DINOv3, experimental This device Dense tokens plus clustering Polygons; boxes in part mode No account
"Find similar - no AI", Beta This device Colour, gradients, grayscale template, or keypoints Boxes No account (may be restricted by the server)
Vision Lab similarity ranking This device One vector per image (DINOv2-Small, centre crop) Ranked images, no location No account
Worker Visual Similarity GPU worker Detector candidate crops plus dense recall Boxes or masks Paid Remote GPU by arrangement (the public Vision Lab page still lists Anastig-hosted inference as roadmap, so confirm access), or your own machine running Anastig (setup not documented)

The first four are in Studio (try it from the annotation demo) or Vision Lab.

Per its published application, the browser Visual Similarity engine cuts the image into at most 36 tiles and computes unit patch descriptors for each. For a box on the current image it slides the reference's patch grid, and its mirror image, over the placements; for an uploaded example, several examples (up to three) or searches across other images it uses a mean descriptor. Both are rescaled with the median-relative formula above, with automatic floors of 0.5 and 0.45 respectively that your own threshold can replace (further matches of the first kind must also reach three quarters of the best one). One run covers at most eight loaded images; there is no dataset-wide index. Results enter a review queue where a label is required before accepting. Its whole-object versus part selector applies to INSID3 on this device, not to this DINOv2 engine; INSID3's whole-object mode returns the containing region, and its part mode switches to a DINOv2-Small template search. The first use downloads model weights (from about 24 MB for the smallest to about 600 MB for the large ones), and DINOv3 is distributed under Meta's own DINOv3 License.

The experiment above is not Anastig and is not evidence about its accuracy: no Anastig engine was run for this article, and no accuracy figures for these tools are available to quote.

What "this device" and "GPU worker" mean for your data is covered in local computer vision inference.

When you can name what you want rather than show it, see text-prompt object detection and segmentation.

What to remember

Similarity depends on the backbone, the crop, the aggregation, the rescaling and the rest of the picture. Treat a score as a ranking within one image under one setup, keep a person between candidates and labels, and test with distractors that differ in exactly the attribute you care about.

References