Tutorial 2: Peak Detection
Peak detection relies on mlgidDETECT package.
First, create the mlgidBASE class instance:
from mlgidbase import mlgidBASE
filename = '../../example/BA2PbI4.h5'
analysis = mlgidBASE(filename=filename)
INFO - Failed to extract font properties from /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf: Can not load face (unknown file format; error code 0x2)
INFO - generated new fontManager
2026-05-26 14:09:55.283824876 [W:onnxruntime:Default, device_discovery.cc:283 GetGpuDevices] Failed to detect devices under "/sys/class/drm/card0": device_discovery.cc:93 ReadFileContents Failed to open file: "/sys/class/drm/card0/device/vendor"
Then run detection:
Minimal Code Example
analysis.run_detection()
INFO - Model file does not exist.
INFO - Starting download of model file to /home/docs/.local/share/mlgiddetect/dino.onnx
[######--------------------------------------------] 12.2% 118.5/968.4 MB 236.94 MB/s
[#############-------------------------------------] 27.2% 263.9/968.4 MB 290.64 MB/s
[####################------------------------------] 41.4% 400.5/968.4 MB 273.30 MB/s
[#############################---------------------] 58.4% 565.6/968.4 MB 330.23 MB/s
[####################################--------------] 72.6% 702.7/968.4 MB 274.07 MB/s
[########################################----------] 80.3% 777.2/968.4 MB 136.48 MB/s
[###############################################---] 94.1% 911.3/968.4 MB 263.56 MB/s
[##################################################] 100.0% 968.4/968.4 MB 252.97 MB/s
INFO - Model file downloaded successfully from https://huggingface.co/mlgid-project/mlgidDETECTdino/resolve/main/model.onnx?download=true to /home/docs/.local/share/mlgiddetect/dino.onnx
INFO - Loading model
INFO - Saved detected peaks to file: ../../example/BA2PbI4.h5, entry: entry_0000, frame: 0
Parameters
entry(str) — Data file entry to process. Defaults toNone(all entries). OPTIONALframe_num(int/List[int]) — Frame number in each entry for detection / list of frames. Defaults toNone(all frames).config_file(str) — Path to detection configuration file. Defaults toNone(default parameters). OPTIONALmodel_type(str) — Name of the modeldinoorfaster_rcnn. OPTIONAL
Decription
The user can specify a single entry or process all entries in the file by setting entry=None. The frame_num parameter accepts either a single int or a list of frame indices to process.
The detection configuration can be loaded from a YAML file. Additionally, the detection model can be selected via the model_type parameter. Currently, two models are supported: dino and faster_rcnn, as described in the recent work by C. Völter.
Informational logs indicate whether the detection model is being loaded. After the initial load, both the model and its configuration remain fixed; any subsequent configuration inputs will be ignored. To apply a different configuration, a new mlgidBASE instance must be created with the desired settings.
analysis = mlgidBASE(filename=filename)
analysis.run_detection(
entry='entry_0000',
frame_num=0,
config_detect='../../example/config.yaml',
model_type = 'faster_rcnn')
ERROR - Configuration file not found: ../../example/config.yaml
An exception has occurred, use %tb to see the full traceback.
SystemExit
/home/docs/checkouts/readthedocs.org/user_builds/mlgidbase/envs/stable/lib/python3.11/site-packages/IPython/core/interactiveshell.py:3756: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
The results can be visualized using silx view or loaded from the saved file, as shown in Tutorial 8.