Skip to content

Add the DE SpotNet spot detector and center refinement networks - #25

Merged
arthurmccray merged 3 commits into
electronmicroscopy:mainfrom
CSSFrancis:de-spotnet
Oct 16, 2026
Merged

arthurmccray merged 3 commits into
electronmicroscopy:mainfrom
CSSFrancis:de-spotnet

Conversation

@CSSFrancis

@CSSFrancis CSSFrancis commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Adds Direct Electron's diffraction spot (Bragg disk) networks as twelve kind: weights entries (each network as an ONNX graph and as a torch checkpoint), served from Zenodo record 23383572 (DOI 10.5281/zenodo.23383571), licensed CC BY-NC 4.0.

Entry File Role
DE_SpotNet de_spotnet.onnx default spot detector (scale-robust)
DE_SpotNet_Dynamical de_spotnet_dynamical.onnx detector fine-tuned on dynamical disks, with a disk-coverage head
DE_SpotNet_Production de_spotnet_production.onnx detector variant, higher recall at the canonical disk size
DE_SpotNet_Base16 de_spotnet_base16.onnx earlier detector, kept as a fallback
DE_CenterNet de_centernet.onnx re-places each detected disk on the raw pattern; gives a positional sigma
DE_FriedelNet de_friedelnet.onnx Friedel-partner refinement after DE_CenterNet
  • The six entries above point at ONNX graphs (model.framework: onnx, model.class: onnxruntime.InferenceSession), so pyxem and quantem can run them without torch.
  • Each has a _Torch partner (DE_SpotNet_Torch, ..., DE_FriedelNet_Torch) for the .pt checkpoint in the same record (model.framework: torch), which training and fine-tuning start from. The descriptions cross-reference each pair.
  • Checksums and sizes are filled in (this comes from a fork, so the fill-in workflow cannot push).
  • One dated version each, "261015".
  • Used by pyxem (Add get_diffraction_vectors(method="neural") on ONNX Runtime with an anywidget GUI, and device= for faster template matching pyxem/pyxem#1194, get_diffraction_vectors(method="neural")) and quantem (BraggVectors.detect_disks(method="neural")).

Checked locally: --validate passes for all twelve, the stub is regenerated (_create_stubs --check clean), the test suite passes (376 passed), ruff and basedpyright are clean, and every entry downloads through emdatabase.data.<Entry>().download(version="261015") with its md5 verified; the ONNX graphs run in ONNX Runtime.

The second commit makes dataset_files sort on the POSIX path string: Windows Path objects compare case-insensitively, so a stub generated on Windows put LayeredCuNb4DSTEM before LSMOLineScan and failed the stub check on Linux.

…tworks

Six kind: weights entries for Direct Electron's networks, served as ONNX
graphs from Zenodo record 23383572 (CC BY-NC 4.0): four spot detectors
(DE_SpotNet, DE_SpotNet_Dynamical, DE_SpotNet_Production,
DE_SpotNet_Base16) and the two center refiners that follow them
(DE_CenterNet, DE_FriedelNet). The matching torch checkpoints sit in the
same record for training and fine-tuning.
dataset_files sorted Path objects, and Windows paths compare
case-insensitively, so a stub generated on Windows put LayeredCuNb4DSTEM
before LSMOLineScan and failed the stub check on Linux CI. Sort on the
POSIX path string instead, which is the order CI already produced.
One *_Torch entry per network for the .pt checkpoints in the same Zenodo
record, which training and fine-tuning start from (quantem's
teach-on-your-marks needs them). Each ONNX entry now names its _Torch
partner and vice versa.
@CSSFrancis

Copy link
Copy Markdown
Contributor Author

@arthurmccray do you want to review this? Not sure exactly how we should be distributing these. The ONNX models are nice so they aren't so tied to pytorch

@arthurmccray

Copy link
Copy Markdown
Collaborator

yup I'll try and get to it today!

@arthurmccray arthurmccray left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, zenodo is down (again) but I trust all the links will work when it's back up

@arthurmccray
arthurmccray merged commit cce85d3 into electronmicroscopy:main Oct 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants