lm3_landmark_detector__yolo26x_pose_640_canonical
YOLO26x-pose model predicting a 31-keypoint leaf skeleton (mid15_pet5) on single-leaf crops from herbarium specimen sheets, trained on corrected landmark labels. Default landmark_detector model for LeafMachine3, replacing lm3_landmark_detector__yolo26x_pose_640 with the same input, output, and keypoint order.
LM3 metadata
| Field | Value |
|---|---|
| LM3 action | landmark_detector |
| LM3_default_model | true |
| LM3_version | 3.0.0 (minimum supported; later releases remain compatible) |
| Model key | yolo26x_pose_640_canonical (training run yolo26x-pose-640-strict-it2labels) |
| Replaces | lm3_landmark_detector__yolo26x_pose_640 |
| Architecture | YOLO26x pose, end-to-end (NMS-free) |
| Base weights | yolo26x-pose.pt (Ultralytics, AGPL-3.0) |
| Input | leaf crop with a 10% white border on every side, 640 letterbox, RGB (see below) |
| Output | 1 box class leaf + 31 keypoints (x, y, conf), order below |
| Keypoints (31) | lamina_tip; apex_left, apex_center, apex_right; midvein_0 .. midvein_14; base_left, base_center, base_right; lamina_base; petiole_0 .. petiole_4, petiole_tip; width_left, width_right |
| flip_idx | [0, 3, 2, 1, 4..18, 21, 20, 19, 22..28, 30, 29] (left/right apex, base, width swap) |
| Trained | 2026-11-06 |
| Iteration | 3 |
Files
| Folder | File | Use |
|---|---|---|
pytorch/ | best.pt | Ultralytics, retraining |
onnx/ | model.onnx | LM3 default runtime (onnxruntime) |
coreml_fp32/ | model.mlpackage/, model.json | LM3 on macOS: Core ML on the Apple GPU, float32 |
torchscript/ | model.torchscript | libtorch |
openvino/ | model_openvino_model/ | Intel CPU/iGPU |
eval_holdout/ | pytorch/, onnx/, torchscript/, openvino/ | variant held out from the evaluation dataset (below); not used by LM3 |
docs/ | *.jpg | label-correction examples, model comparison, example overlays |
SHA-256 of every file is in manifest.json. Keypoint names, kpt_shape, and flip_idx are in manifest.json and training_metadata.json. evaluation_comparison.json holds the comparison with the previous default.
Input preprocessing (what the model sees)
Training images are single-leaf crops padded with a 10% white border per side; the box is the un-padded crop region (central 1/1.2 of the canvas) and keypoints are mapped into the padded frame. At inference the same 10% white pad must be added before the 640 letterbox, and keypoints mapped back by (p - 0.1) * 1.2 in normalized coordinates. Unpadded crops are not supported.
Training data
Dataset LM3_Landmarks_Pose_it2, built 2026-11-04 by correcting the labels of LM3_Landmarks_Pose (23 Labelbox landmark projects): same images, same 80/10/10 split, same mid15_pet5 resampling. 15,178 single-leaf crops, one leaf instance per image. Images and labels are not distributed.
| Split | Images | Keypoint instances |
|---|---|---|
| train | 12,225 | 357,929 |
| val | 1,387 | 40,598 |
| test | 1,566 | 45,807 |
What was corrected
The original labels recorded how each leaf happened to be drawn rather than one rule. The corrections apply one anatomical rule to every leaf: with the tip up and the petiole down, left and right are relative to the midvein. Nothing was re-annotated by hand; the corrections are computed from the drawn geometry. 8,632 of 15,178 crops changed.
| Correction | Crops | What changed |
|---|---|---|
| Left/right order | width 5,351 · apex 4,562 · base 4,990 | Pairs had often been stored in the order they were clicked on screen, so *_left could be either side of the leaf. Each pair is now ordered by the leaf: *_left is left of the midvein with the tip up. |
| Midvein direction | 619 | Midveins drawn from the base were stored backwards. midvein_0 is now always at the tip end. |
| Petiole tip | 2,342 moved, 151 filled in | petiole_tip was sometimes put at the junction with the blade. It is now always the free end of the petiole trace. |
| Angle drawn as two separate arms | apex 304 · base 303 | Only one arm had been kept, so the three angle points lay on one line. The arms are now merged into one vertex and two arms. |
| Angle drawn with extra vertices | apex 310 · base 406 | The center point had been the middle of the line, not the vertex. The two ends are now the arms and the interior vertex nearest the tip (or base) is the center. |
| Width drawn with extra vertices | 63 | The width had been the first and last clicks, which could be side by side. It is now the longest chord. |
234 points or pairs that could not be oriented (for example, a midvein with no tip or base to tell its direction) are marked not labeled rather than guessed. 39 crops with nothing usable left were dropped.
Drawn with the leaf tip up. Orange = left point, blue = right point, teal = midvein (arrows run from midvein_0 toward the base), violet = petiole, diamond = petiole_tip, dark dots = lamina tip and base and the angle vertices.
Why this helps. Pose training scores each predicted keypoint against the label with the same index, and augmentation rotates leaves up to 180° and mirrors them. When about a third of the pairs follow screen order, the same point of the leaf carries opposite labels on similar images, so the model cannot learn which side is which. The previous model hedged: some widths and angle arms collapsed toward the midvein, and longer training on the old labels made left and right points drift across the leaf. With one rule for every leaf, the model learns the rule.
Training
300 epochs, no early stopping, cosine LR, batch 9, close_mosaic=150 (mosaic off for the final 50%), single_cls. Loss gains: box 2.0, cls 0.5, dfl 1.5, pose 20.0, kobj 2.0. Per-keypoint strictness: the 11 non-trace keypoints (lamina_tip, apex x3, base x3, lamina_base, petiole_tip, width x2) use OKS sigma 1/124 instead of 1/31 and 4x RLE weight; the 20 trace points keep 1/31. Augmentation: hsv 0.015/0.7/0.4, degrees 180, translate 0.1, scale 0.5, fliplr 0.5, mosaic 1.0. best.pt is epoch 206, chosen on pose mAP50-95 alone (Ultralytics' default also adds the box mAP of the single crop-sized box).
Evaluation
| Split | Box mAP50 | Box mAP50-95 | Pose mAP50 | Pose mAP50-95 | Pose P | Pose R |
|---|---|---|---|---|---|---|
| val | 0.995 | 0.795 | 0.883 | 0.570 | 0.915 | 0.914 |
| test | 0.995 | 0.798 | 0.847 | 0.550 | 0.894 | 0.896 |
Pose metrics use OKS with the uniform 1/31 sigma per keypoint. Evaluated with Ultralytics val on best.pt at 640 on the corrected labels (evaluation_metrics.json).
Compared with the previous default
Both models scored on the same corrected labels.
| This model | Previous default | |
|---|---|---|
| Pose mAP50-95, val / test | 0.570 / 0.550 | 0.542 / 0.527 |
| Pose mAP50-95 through the LM3 ONNX runtime, val / test | 0.546 / 0.527 | 0.525 / 0.508 |
| Width / apex / base pairs on the correct sides, test | 98.4 / 97.4 / 98.0% | 97.0 / 93.9 / 95.8% |
| Width length error, median / 90th percentile, test | 2.2% / 9.5% | 4.0% / 16.8% |
| Apex / base angle error, median, test | 8.0° / 7.6° | 9.7° / 8.8° |
Sides, width, and angles use each model's top-confidence prediction; width error is relative to the labeled width. Points on the midline (lamina tip and base, midvein, petiole) are placed slightly less precisely than by the previous default (median error 0.1–0.2% of leaf length higher). The previous card's scores were measured on the original labels and are not comparable with these.
Before and after
Random test leaves: corrected label, previous default, this model.

Test leaves where the previous default put a width, apex, or base pair on the wrong side or on one side, or collapsed the width (selected, not random).

Drawn with the leaf tip up. Orange = left point, blue = right point, teal = midvein (arrows run from midvein_0 toward the base), violet = petiole, diamond = petiole_tip, dark dots = lamina tip and base and the angle vertices.
Examples
LeafMachine3 Reporter overlays of this model's keypoints on plant_detector leaf crops (midvein and petiole traces, apex/base angle lines, width line) with the derived landmark_measurements. Full-size images are in docs/.
Variant held out from the evaluation dataset (eval_holdout/)
Same architecture and training recipe, retrained on LM3_Landmarks_Pose_it3: the corrected labels above with the split redrawn so that all 250 leaves of the LM3 landmark evaluation dataset are in test. Use this variant to report scores on that dataset. The default model above trained on 63 of those leaves and validated on 11 more, and its predictions were the starting labels for the other 165, so its scores there are optimistic. LeafMachine3 keeps using the default model.
Training: as above; best.pt is epoch 281. Data: 12,232 train / 1,428 val / 1,683 test crops (test: 1,433 leaves from the labeled pool plus the 250 evaluation leaves). eval_holdout/ holds pytorch/best.pt, onnx/model.onnx (opset 18), torchscript/model.torchscript, openvino/model_openvino_model/, training_metadata.json and evaluation_metrics.json.
| Pose mAP50-95 (mAP50) | eval_holdout/ | Default |
|---|---|---|
| Test leaves neither model trained or validated on, outside the evaluation dataset (1,037) | 0.541 (0.829) | 0.550 (0.849) |
| Evaluation dataset, all 250 leaves | 0.757 (0.959) | 0.802 (0.969)* |
| Evaluation dataset, 201 leaves with all 31 keypoints | 0.799 (0.976) | 0.837 (0.979)* |
* Not held out (see above). Ultralytics val at 640 with the uniform 1/31 OKS sigma; the evaluation dataset's own scripts (LM3's ONNX path) are on its card.
from huggingface_hub import hf_hub_download
path = hf_hub_download("phyloforfun/lm3_landmark_detector__yolo26x_pose_640_canonical", "eval_holdout/onnx/model.onnx")
Use in LeafMachine3
Stage landmark_detector (depends on plant_detector). Runs on every Leaf_WHOLE crop (Leaf_PARTIAL optional) with the 10% white pad, ONNX export at 640, conf=0.10, iou=0.45; keypoints are mapped back to the crop and then to the specimen frame and stored per leaf. Downstream consumers: landmark_measurements (traces, lengths, apex/base angles), leaf_orientation, petiole_width, bilateral_symmetry, ect, metric_grounding, and the Reporter overlays.
On macOS, LM3 runs coreml_fp32/ with Core ML on the Apple GPU instead; its output matches this ONNX model to float32 rounding.
from huggingface_hub import hf_hub_download
path = hf_hub_download("phyloforfun/lm3_landmark_detector__yolo26x_pose_640_canonical", "onnx/model.onnx")
Citation
Weaver, W. N. (2026) LeafMachine3. https://leafmachine.org