Small butterfly image encoder (DINOv2-S/14 distilled, int8 ONNX)
A small image encoder (~22.4 M parameters, 26.3 MB as selective int8 ONNX) distilled to imitate the image embedding of BioCLIP 2.5 ViT-H/14 on butterfly photos. It outputs the same L2-normalised 1024-D feature, so it works with the same classifier head. It is the "fast and light" ("Rapido y liviano") option of the offline butterfly identifier in the Ikiam Insectary app (https://ithomiini-ikiam.com/identificar/), small enough to download on mobile data and run on a phone.
Licence
- Distilled weights in this repository: CC BY-NC 4.0 (non-commercial), inherited from the frozen classifier head (fr4nzzch/butterfly-id-classifier, CC BY-NC 4.0) used in the KL distillation loss and the predominantly non-commercial training photos.
- Upstream starting weights:
vit_small_patch14_reg4_dinov2(DINOv2-S/14 with 4 registers, via timm) is Apache-2.0 (used forstudent_W2_int8.onnxandstudent_SB_int8.onnx);vit_small_patch16_224(ImageNet-21k augreg, used forstudent_L1_int8.onnx) is Apache-2.0; teacher BioCLIP 2.5 ViT-H/14 is MIT.
Files
All three historical small models stay in this repository so older builds and rollbacks keep working:
| File | Version | Input | Bytes | SHA-256 | Status |
|---|---|---|---|---|---|
student_W2_int8.onnx | small-W2-20261123 | [b, 3, 182, 182] float32 | 26,327,311 | 52c76bd7de48fa228be885c9fa3d1d9af112cd838b25fd2e80d7dbc63ea6cd74 | Current |
student_SB_int8.onnx | small-SB-20261111 | [b, 3, 182, 182] float32 | 23,380,320 | 200343ee87918fb7b8e2d2ff8433d9aa54995c9921ab5b8f942ff3ab25385762 | Previous (rollback) |
student_L1_int8.onnx | small-L1-20261031 | [b, 3, 192, 192] float32 | 23,565,423 | d6bdc3e5f8721b6ff707b4f46625cc8d8c9af86c0df757f9b2619aed1cc2f5fb | Legacy (pre-versions) |
Tensor contract (student_W2_int8.onnx and student_SB_int8.onnx)
- Input:
pixel_values,float32[b, 3, 182, 182](224 px wing-detector crop normalised with CLIP mean/std, bilinearly resized without antialias to 182 px; CLIP-to-ImageNet renormalisation is inside the ONNX graph). - Output:
feature,float32[b, 1024]L2-normalised embedding in BioCLIP 2.5's feature space.
How student_W2_int8.onnx was made (November 2026)
- Student: DINOv2-S/14 reg4 (
vit_small_patch14_reg4_dinov2, Apache-2.0) at 182 px with a linear projection to 1024-D. - Training: 80 epochs (60,400 steps) of cached BioCLIP 2.5 ViT-H/14 distillation (
cos_w=5.0, kl_w=2.0, T=0.5, label_w=0.5) with layer-wise learning rate decay (base_lr=6e-4, llrd=0.80, lr_head_mult=1.5, wd=0.05). - Quantization: Dynamic
QInt8(onnxruntime 1.20.1, opset 17,per_channel=False) with 2 linear layers kept in fp32 (backbone.blocks.4.mlp.fc2+/proj/Gemm; 47MatMulIntegernodes vs 49 instudent_SB_int8.onnx) to prevent an LLRD activation-outlier collapse. Mean cosine vs fp32 on 8,845 dev crops:0.998835, top-1 agreement:97.44%.
Evaluation (student_W2_int8.onnx vs student_SB_int8.onnx)
- Frozen
S2fresh confirm set (never-seen post-7 Nov 2026 Neotropical iNaturalist butterflies, production head6fa6ab78,s2_e2e_i25detector crops, observer-clustered bootstrap 95% CI):- All-butterfly species top-1 (
N=792, 585 observers): 84.72% vs 82.70% (+2.02 pp[0.00, +3.95], 37 up / 21 down). - Genus top-1 (
N=792): 92.05% vs 91.04% (+1.01 pp[-0.27, +2.33], 16 up / 8 down). - Corrected Ithomiini top-1 (
N=43, 38 observers): 86.05% vs 86.05% (0.00 pp). - Out-of-vocab
p1 >= 0.9rate (N=113, 104 observers): 10.62% vs 8.85% (+1.77 pp[-1.73, +5.26], 12/113 vs 10/113).
- All-butterfly species top-1 (
- 1-thread ORT-web WASM latency (31 interleaved browser runs): 128.5 ms vs 126.0 ms (1.020x).
Treat the first guess as a starting point and compare with reference photos; displayed scores are not calibrated probabilities on out-of-vocabulary species.
How the app uses it
Wing detector (fr4nzzch/butterfly-wing-detector-onnx,
AGPL-3.0) -> crop -> this encoder -> normalised feature -> classifier head
(fr4nzzch/butterfly-id-classifier, offline/), all in the
browser. Downloaded once and kept on the device; photos are not uploaded.