Skip to main content
Resume
← All projects

Computer vision research

DinoPatch

An early instance-aware anomaly-detection experiment using segmentation, aligned crops, and dense DINOv2 patch features.

A visual anomaly heatmap produced by the DinoPatch work
Patch-level anomaly localization from the DinoPatch experiments.
Status Completed — predecessor to makroInspect · 2024
Technologies
  • Python
  • PyTorch
  • SAM2
  • DINOv2
  • OpenCV
  • NumPy
  • VisA
  • Jupyter

Overview

DinoPatch is the experimental predecessor to makroInspect. The notebook explores unsupervised visual anomaly detection on VisA categories using normal training examples, object segmentation, normalized crops, and dense transformer features.

Its purpose was to test whether instance-level alignment and spatially preserved DINOv2 features could reduce irrelevant visual variation before nearest-neighbour anomaly scoring. makroInspect is the current, actively developed continuation of this work — its results supersede anything reported here.

Problem and context

Patch-based anomaly detection is sensitive to position, orientation, background, and scale. In multi-instance product images, a whole-frame embedding can mix several objects and make the background part of the learned normal distribution.

The experiment therefore needed to isolate candidate objects while retaining the local feature grid required to show where a defect occurs.

Technical approach

SAM2 automatic masks isolate object instances. Oriented bounding boxes and mask-aware cropping rotate and resize each instance to a consistent working frame.

DINOv2 ViT-B/14 produces dense patch embeddings. Orientation checks align equivalent instances, and normal feature grids are stacked into an object-specific reference bank for later distance-based scoring and visualization.

Key engineering details

Dataset preparation

The notebook parses VisA train and test splits per object category and keeps normal references separate from labelled anomaly samples and masks.

Instance normalization

SAM2 masks, oriented rectangles, padding, and fixed-size crops reduce background and pose variation before feature extraction.

Dense feature bank

Patch tokens remain a two-dimensional feature grid rather than being collapsed into a single image vector, preserving the spatial basis for a heatmap.

Research progression

The notebook format made rapid experiments practical, but also exposed the need for explicit stages, cached artifacts, run state, and selective invalidation.

Results and outcomes

DinoPatch established the instance-segmentation, alignment, and dense-patch direction used in the later system. It remains an experimental research snapshot rather than the current production structure.

makroInspect carries the work forward with SAM3, PatchCore-style memory-bank selection, a staged file-based pipeline, cached artifacts, configuration-aware invalidation, and multi-dataset evaluation. See the makroInspect case study for current results.