UNet++ with an EfficientNet-B7 encoder that separates plant material from everything else on a herbarium specimen sheet (binary foreground mask, used for background removal). Was the default specimen_segmenter model in LeafMachine3 3.0.0 to 3.0.1041; the current default is lm3_specimen_segmenter__unetpp_effb7_1024_dinov3_vith16plus_2048_consensus (UNet++ v8). This model stays available as an alternate (lm3 models install --model specimen_segmenter=unetpp_effb7_1024).
| Field | Value |
|---|---|
| LM3 action | specimen_segmenter |
| LM3_default_model | false (the default in 3.0.0 to 3.0.1041; now unetpp_effb7_1024_dinov3_vith16plus_2048_consensus) |
| LM3_version | 3.0.0 (minimum supported; later releases remain compatible) |
| Model key | unetpp_effb7_1024 (training run unet_masksFromSam3_paperclean_control_1024) |
| Input | whole sheet image, letterboxed onto a white 1024 x 1024 square, RGB, ImageNet mean/std normalization; tensor input [1, 3, 1024, 1024] float32 |
| Output | logits [1, 1, 1024, 1024]; apply sigmoid, threshold 0.5, remove the letterbox pad, resize to the sheet |
| Classes (1) | plant (foreground) |
| Trained | 2026-07-28 |
| Component | Detail |
|---|---|
| Network | UNet++ (nested, densely connected skip pathways), segmentation_models_pytorch.UnetPlusPlus |
| Encoder | EfficientNet-B7, initialized from ImageNet weights (encoder_weights="imagenet") |
| Head | 1 output channel, no activation (logits) |
| Parameters | 66.4 M |
| Exported weights | the exponential-moving-average copy (decay 0.9998) of the best epoch |
The whole network is fine-tuned; only the encoder starts from pretrained weights.
| Folder | File | Use |
|---|---|---|
pytorch/ |
best.pt |
training checkpoint (model, EMA, optimizer); retraining |
onnx/ |
model.onnx |
LM3 default runtime (onnxruntime), opset 17 |
torchscript/ |
model.torchscript.pt |
libtorch |
coreml/ |
model.mlpackage/ |
Apple devices |
docs/ |
compare_*.jpg |
example panels (see Examples) |
SHA-256 of every file is in manifest.json.
There is no hand-drawn ground truth for this task. The training targets are machine-generated masks, refined in three steps:
Specimen boxes from the LeafMachine3 plant detection set prompt SAM 3; the per-box masks are unioned, holes filled, and failed masks gated out. 21,098 sheets kept.The result is dataset LM3_Specimen_Segmentation-specimen-unetMasksFromSam3-paperclean: 18,904 sheet images from 75 labeling projects, one plant class. Images and masks are not distributed.
| Split | Images |
|---|---|
| train | 15,154 |
| val | 1,910 |
| test | 1,840 |
34 epochs, batch 4, 1024 x 1024 letterbox, AdamW (lr 1e-4, weight decay 1e-4), cosine schedule, mixed precision, EMA. Loss: Dice + binary cross-entropy + 0.5 x boundary (Sobel edge) term. Augmentation: horizontal and vertical flips, 90-degree rotations, transpose, brightness/contrast 0.2, hue/saturation/value 10/15/10.
Scores are agreement with the machine-generated masks described above, not with human annotation. They measure how well the model reproduces its training targets on held-out sheets; a model that corrects a flawed target is penalized for it. Read them as a consistency check and judge quality from the examples.
| Split | Sheets scored | Dice (mean) | Dice (median) | IoU (mean) |
|---|---|---|---|---|
| val, during training (best epoch) | 1,910 | 0.946 | ||
| val, exported ONNX | 150 of 1,910 | 0.941 | 0.979 | 0.909 |
| test, exported ONNX | 150 of 1,840 | 0.948 | 0.977 | 0.916 |
The ONNX rows are random samples of each split, scored at native sheet resolution; 2% of test sheets and 3% of val sheets score below 0.5 Dice. Known weakness: faint, dried-brown material on similarly colored paper can be under-segmented.
Background removal on the same sheets by this model (UNet++) and by the two other LeafMachine3 specimen segmenters trained on the same data, BiRefNet and YOLO26x-seg, for comparison. Black marks what each model removed; the percentage is the share of the sheet kept. Raw model masks, before LeafMachine3's paper-removal follow-up. File names give each sheet's dataset split. Panels 1 to 12 are a standing comparison set that includes deliberately hard sheets (several from the training split); panels 13 to 20 are random held-out test sheets.
Acer saccharum, CMN_1804514859 · test split · kept: UNet++ 40.1%, BiRefNet 40.2%, YOLO26x-seg 47.1% |
Acer saccharum, CM_2859177966 · train split · kept: UNet++ 28.5%, BiRefNet 28.5%, YOLO26x-seg 32.4% |
Cassia fistula, FLAS_1457816931 · val split · kept: UNet++ 23.0%, BiRefNet 23.3%, YOLO26x-seg 23.8% |
Chrysophyllum gonocarpum, NY_1928830727 · val split · kept: UNet++ 22.6%, BiRefNet 22.2%, YOLO26x-seg 30.8% |
CHC21_009_9 · val split · kept: UNet++ 2.6%, BiRefNet 2.6%, YOLO26x-seg 2.7% |
Macaranga saccifera, MNHN_730851102 · val split · kept: UNet++ 44.4%, BiRefNet 44.6%, YOLO26x-seg 49.3% |
Macaranga magnifolia, MNHN_731821562 · train split · kept: UNet++ 11.0%, BiRefNet 0.5%, YOLO26x-seg 47.6% |
Macaranga gracilis, UM_1807486051 · train split · kept: UNet++ 31.2%, BiRefNet 34.0%, YOLO26x-seg 37.8% |
Torricellia angulata, K_912592861 · train split · kept: UNet++ 22.7%, BiRefNet 24.2%, YOLO26x-seg 27.5% |
Quercus grisebachii, CLF_1437883182 · train split · kept: UNet++ 22.5%, BiRefNet 23.5%, YOLO26x-seg 23.8% |
Quercus semilanuginosa, CLF_1437893278 · train split · kept: UNet++ 20.5%, BiRefNet 32.1%, YOLO26x-seg 29.5% |
Quercus pinnatiloba, MNHN_731018123 · train split · kept: UNet++ 33.0%, BiRefNet 32.7%, YOLO26x-seg 33.7% |
Lonicera maackii, KYO_2443051967 · test split · kept: UNet++ 15.1%, BiRefNet 15.5%, YOLO26x-seg 19.2% |
Macaranga waturandangii, BO1284103_4067113860 · test split · kept: UNet++ 33.8%, BiRefNet 34.1%, YOLO26x-seg 35.6% |
Melanophylla alnifolia, L_2517447339 · test split · kept: UNet++ 22.2%, BiRefNet 21.9%, YOLO26x-seg 23.7% |
Raphanus raphanistrum, ASU_2270499210 · test split · kept: UNet++ 10.0%, BiRefNet 10.2%, YOLO26x-seg 15.7% |
Posoqueria longiflora, UM_1807432107 · test split · kept: UNet++ 29.4%, BiRefNet 29.5%, YOLO26x-seg 31.4% |
1D41D09F-BC60-4E11-9283-3A0F23787BA7_1_105_c · test split · kept: UNet++ 24.9%, BiRefNet 24.9%, YOLO26x-seg 27.8% |
Piper salinasanum, MNHN_438671634 · test split · kept: UNet++ 12.1%, BiRefNet 12.0%, YOLO26x-seg 13.3% |
lab_tilia_tomentosa_ny1110-08-4 · test split · kept: UNet++ 7.5%, BiRefNet 7.5%, YOLO26x-seg 7.7% |
Stage specimen_segmenter (no dependencies; runs on the whole working image, independent of the plant boxes). ONNX at 1024, sigmoid threshold conf (default 0.5), then the paper-removal follow-up (paperclean: true). One mask per specimen is stored; the Reporter draws it as Overlay_Specimen_Segmentation and exports it under Specimen_Masks (binary mask and RGB cutout).
from huggingface_hub import hf_hub_download
path = hf_hub_download("phyloforfun/lm3_specimen_segmenter__unetpp_effb7_1024", "onnx/model.onnx")
Weaver, W. N. (2026) LeafMachine3. https://leafmachine.org
pytorch/best.pt 549 MBtorchscript/model.torchscript.pt 276 MBonnx/model.onnx 266 MBcoreml/model.mlpackage/Data/com.apple.CoreML/weights/weight.bin 133 MB