Instructions to use phyloforfun/lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use phyloforfun/lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="phyloforfun/lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("phyloforfun/lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp", device_map="auto") - Notebooks
- Google Colab
- Kaggle
lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp
Frozen DINOv3 ViT-S/16 backbone with a trained MLP head, classifying ruler unit type (19 classes) on squarified ruler crops from herbarium specimen sheets. The default and only LeafMachine3 ruler_classifier model going forward: it replaces the 3-model ensemble (yolo26x_cls_224, yolo26n_cls_224, dinov2_frozen_mlp); there is no more voting. Not yet wired into LeafMachine3 (version: null): the current stage still runs the ensemble.
LM3 metadata
| Field | Value |
|---|---|
| LM3 action | ruler_classifier |
| LM3_default_model | true (sole model; replaces the ensemble) |
| LM3_version | 3.0.1056 |
| Model key | dinov3_vits16_tile_four_896_mlp |
| Architecture | facebook/dinov3-vits16-pretrain-lvd1689m (frozen) -> concat(CLS, mean of patch tokens) of the last layer (768) -> standardize -> MLP (768 -> 512, GELU, dropout 0.2 -> 19) |
| Base weights | facebook/dinov3-vits16-pretrain-lvd1689m (Meta, DINOv3 License, see LICENSE.md); only the head is trained |
| Input | squarified crop, 896 x 896 (tile_four, sz=448; bilinear resize to 896 if needed), RGB in [0,1], ImageNet mean/std normalization |
| Output | raw logits over 19 classes (apply softmax), order in label_map.json |
| Classes (19) | FP, GRID_CM, METRIC_CM, METRIC_CM2, METRIC_CM4, METRIC_CM5, METRIC_CM_BLOCK, METRIC_CM_STAGGER, METRIC_MM, METRIC_MM2, METRIC_MM_CM, METRIC_MM_CM_BLOCK, METRIC_MM_IN16, STD_IN16, STD_IN16_IN8_IN2, STD_IN32_IN16, STD_IN8, STD_IN8_CM, messy |
| Trained | 2026-11-02 |
| Iteration | 3: new class METRIC_CM5, a rare-class supplement of 8,308 crops, and 104 label corrections after reviewing iteration-2 model errors |
Files
| Folder | File | Use |
|---|---|---|
pytorch/ |
ckpt_best.pt |
backbone + head state (torch, fp32), retraining |
onnx/ |
model.onnx |
LM3 runtime (onnxruntime); backbone + head in one graph, opset 17, dynamic batch |
label_map.json |
class order | |
LICENSE.md |
DINOv3 License (applies to the backbone weights in both files) | |
docs/ |
example_{cm_tick,block,mm_tick}_{crop,squarified}.jpg |
before/after preprocessing examples |
SHA-256 of every file is in manifest.json.
Input preprocessing (what the model sees)
The model is never run on the raw ruler crop. Every Ruler crop from archival_detector is first squarified: rotated to landscape, converted to grayscale, and tiled into a 896 x 896 collage of four views of the same strip (LM2 tile_four, sz=448: stacked / max-height / quartiles / nine). The collage is the prediction input. Note the size: the ensemble used sz=720 (1440 x 1440) resized to 224; this model needs sz=448 and no resize. Feeding it a raw strip is unsupported.
Examples. Left: raw crop from the archival detector. Right: the squarified prediction input (896 x 896).
Training data
Dataset ruler-classifier-iteration3-cleaned-labels-dataset (it3-cleaned-v1, signature babdeb23350a9345): 22,015 grayscale ruler crops, 19 classes.
- 13,707 crops of every
Rulerdetection in the 67LM3_Archivalprojects (the iteration-1/2 set). - 8,308 rare-class supplement crops, cut by LM3's archival detector from sheets of the 23 herbaria whose rulers were under-represented, each filed by hand. New class
METRIC_CM5(metric ruler with a tick every 2 mm, 5 ticks per cm). - Iteration 3: every crop reviewed in a class-folder viewer guided by out-of-fold predictions; 104 labels changed vs iteration 2 (val 21, train 64, test 19), mostly METRIC_CM2 → METRIC_MM: 26, METRIC_CM → METRIC_MM: 12, METRIC_MM → messy: 9, FP → messy: 8, messy → METRIC_MM: 8, METRIC_MM → STD_IN16: 6.
- Split 70/15/15 grouped by parent sheet (12,591 sheets: all crops of a sheet share a partition), stratified by class, seed 0. Images and labels are not distributed.
| Class | train | val | test |
|---|---|---|---|
| FP | 2,225 | 476 | 478 |
| GRID_CM | 944 | 202 | 200 |
| METRIC_CM | 170 | 37 | 35 |
| METRIC_CM2 | 83 | 18 | 17 |
| METRIC_CM4 | 59 | 13 | 13 |
| METRIC_CM5 | 231 | 50 | 50 |
| METRIC_CM_BLOCK | 229 | 49 | 49 |
| METRIC_CM_STAGGER | 547 | 118 | 118 |
| METRIC_MM | 4,296 | 920 | 923 |
| METRIC_MM2 | 146 | 32 | 32 |
| METRIC_MM_CM | 2,744 | 588 | 588 |
| METRIC_MM_CM_BLOCK | 499 | 107 | 107 |
| METRIC_MM_IN16 | 255 | 55 | 57 |
| STD_IN16 | 592 | 129 | 129 |
| STD_IN16_IN8_IN2 | 148 | 32 | 31 |
| STD_IN32_IN16 | 161 | 34 | 35 |
| STD_IN8 | 1,231 | 264 | 264 |
| STD_IN8_CM | 496 | 107 | 106 |
| messy | 343 | 79 | 74 |
| total | 15,399 | 3,310 | 3,306 |
Training
Backbone frozen; head trained on cached descriptors of the training set (bf16 inference, stored fp16). AdamW, weight decay 1e-4, batch 256, 100 epochs, lr 0.0001 (best of 1e-4 / 3e-4 / 1e-3 on val macro F1, best epoch 73), cross-entropy with effective-number class weights and class-balanced sampling, seed 0, no augmentation. Best val macro F1 0.9975.
Evaluation (test, 3,306 crops)
Re-classified through onnx/model.onnx in LeafMachine3's runtime (onnxruntime-gpu 1.20.2, CUDA, no CPU fallback); identical to the training-time evaluation.
| Accuracy | Balanced accuracy | Macro F1 | Weighted F1 | ms / image (CUDA, batch 1) |
|---|---|---|---|---|
| 0.9991 | 0.9988 | 0.9992 | 0.9991 | 20.6 (NVIDIA RTX 6000 Ada) |
Per-class F1 (support): FP 1.000 (478), GRID_CM 0.998 (200), METRIC_CM 1.000 (35), METRIC_CM2 1.000 (17), METRIC_CM4 1.000 (13), METRIC_CM5 1.000 (50), METRIC_CM_BLOCK 1.000 (49), METRIC_CM_STAGGER 1.000 (118), METRIC_MM 0.999 (923), METRIC_MM2 1.000 (32), METRIC_MM_CM 0.999 (588), METRIC_MM_CM_BLOCK 1.000 (107), METRIC_MM_IN16 1.000 (57), STD_IN16 0.996 (129), STD_IN16_IN8_IN2 1.000 (31), STD_IN32_IN16 1.000 (35), STD_IN8 1.000 (264), STD_IN8_CM 1.000 (106), messy 0.993 (74).
The iteration-3 label review was guided by iteration-2 model errors, including 21 val and 19 test crops, so these test scores are optimistic.
Iteration-3 leaderboard
All 24 runs of the iteration-3 sweep: frozen DINOv3 backbones x squarify versions, MLP head, same data and split; ranked by val macro F1 (test reported, never used to pick). This model in bold. GPU ms / img is the backbone forward in bf16 at the sweep's batch size (PyTorch, no image decode).
| # | backbone | params | input px | squarify | head | val macro-F1 | test macro-F1 | test acc | test bal. acc | GPU ms / img |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | vit7b16 | 6.7B | 448 | tile_four_448 | mlp | 0.998 | 0.998 | 0.999 | 0.999 | 133.73 |
| 2 | vits16 | 22M | 896 | tile_four_896 | mlp | 0.998 | 0.999 | 0.999 | 0.999 | 5.46 |
| 3 | vit7b16 | 6.7B | 448 | nine_448 | mlp | 0.997 | 0.998 | 0.998 | 0.998 | 126.59 |
| 4 | vit7b16 | 6.7B | 448 | quartiles_448 | mlp | 0.997 | 0.999 | 0.999 | 0.999 | 135.59 |
| 5 | vitl16 | 300M | 896 | tile_four_896 | mlp | 0.997 | 0.997 | 0.998 | 0.996 | 39.74 |
| 6 | convnext_base | 89M | 224 | quartiles_224 | mlp | 0.997 | 0.995 | 0.997 | 0.995 | 0.56 |
| 7 | vitl16 | 300M | 896 | quartiles_896 | mlp | 0.997 | 0.998 | 0.998 | 0.998 | 41.72 |
| 8 | vit7b16 | 6.7B | 448 | tile_four_1440 | mlp | 0.996 | 0.999 | 0.999 | 0.999 | 127.83 |
| 9 | vitl16 | 300M | 896 | nine_896 | mlp | 0.996 | 0.999 | 0.999 | 0.998 | 39.66 |
| 10 | vits16 | 22M | 896 | stack_896 | mlp | 0.996 | 0.997 | 0.999 | 0.999 | 5.14 |
| 11 | vits16 | 22M | 896 | tile_four_1440 | mlp | 0.996 | 0.999 | 0.999 | 0.999 | 5.27 |
| 12 | vit7b16 | 6.7B | 448 | stack_448 | mlp | 0.996 | 0.997 | 0.998 | 0.996 | 127.67 |
| 13 | vits16 | 22M | 896 | nine_896 | mlp | 0.996 | 0.999 | 0.999 | 0.998 | 5.70 |
| 14 | vit7b16 | 6.7B | 448 | maxheight_448 | mlp | 0.996 | 0.998 | 0.999 | 0.996 | 134.73 |
| 15 | vitl16 | 300M | 896 | maxheight_896 | mlp | 0.996 | 0.997 | 0.998 | 0.996 | 39.65 |
| 16 | vitl16 | 300M | 896 | tile_four_1440 | mlp | 0.995 | 0.998 | 0.998 | 0.998 | 42.00 |
| 17 | convnext_base | 89M | 224 | stack_224 | mlp | 0.995 | 0.996 | 0.996 | 0.995 | 0.56 |
| 18 | vitl16 | 300M | 896 | stack_896 | mlp | 0.995 | 0.997 | 0.998 | 0.997 | 41.70 |
| 19 | vits16 | 22M | 896 | maxheight_896 | mlp | 0.995 | 0.998 | 0.998 | 0.998 | 5.64 |
| 20 | convnext_base | 89M | 224 | nine_224 | mlp | 0.995 | 0.990 | 0.996 | 0.995 | 0.54 |
| 21 | convnext_base | 89M | 224 | tile_four_1440 | mlp | 0.994 | 0.986 | 0.993 | 0.978 | 0.52 |
| 22 | vits16 | 22M | 896 | quartiles_896 | mlp | 0.993 | 0.998 | 0.999 | 0.997 | 5.25 |
| 23 | convnext_base | 89M | 224 | tile_four_224 | mlp | 0.993 | 0.997 | 0.997 | 0.997 | 0.51 |
| 24 | convnext_base | 89M | 224 | maxheight_224 | mlp | 0.992 | 0.990 | 0.994 | 0.988 | 0.53 |
Use in LeafMachine3
Stage ruler_classifier (depends on archival_detector) runs this model alone. Each Ruler crop is squarified (tile_four, sz=448, 896 x 896) exactly as in training and classified once (softmax over the logits); per-crop unit type and a per-specimen consensus feed ruler_cf (conversion factor). Feeding un-squarified strips is not supported.
from huggingface_hub import hf_hub_download
path = hf_hub_download("phyloforfun/lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp", "onnx/model.onnx")
License
The backbone weights inside pytorch/ckpt_best.pt and onnx/model.onnx are DINOv3 Materials, distributed under the DINOv3 License (LICENSE.md).
Citation
Weaver, W. N. (2026) LeafMachine3. https://leafmachine.org
Siméoni, O., Vo, H. V., Seitzer, M., et al. (2025) DINOv3. arXiv:2508.10104
Model tree for phyloforfun/lm3_ruler_classifier__dinov3_vits16_tile_four_896_mlp
Base model
facebook/dinov3-vit7b16-pretrain-lvd1689m




