mlgidDETECT
This package is included in the mlgidBASE package and can be used as part of the mlgid pipeline.
Clone repository
- Clone with ssh (recommended)
git clone git@github.com:mlgid-project/mlgidDETECT.git - If it fails, use https:
git clone https://github.com/mlgid-project/mlgidDETECT.git
Installation
Install Conda environment (recommended)
-
Install miniconda https://docs.anaconda.com/miniconda/#quick-command-line-install
-
Move into directory:
cd mlgidDETECT -
(Option 1) Create environment with CPU and optional GPU inference
cd setup
conda env create -f conda_cpu.yaml
conda activate mlgiddetect-cpu\ -
(Option 2) Create environment with with additional GPU preprocessing
cd setup
python setup_cuda.py
conda activate mlgiddetect-gpu
conda env config vars set LD_LIBRARY_PATH=${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}
conda deactivate
conda activate mlgiddetect-gpu
SetPREPROCESSING CUDA: Truein the config file
Install package with pip
- Install package
pip install mlgiddetect
Usage
With a PyGIDDataset
python main.py --input_dataset=/home/testuser/dataset.h5
With a single image
python main.py --image_path=./w4_mapbbr32.tif
With a config file
python main.py --config_file=./faster_rcnn.yaml
Model selection & ensemble
Models are configured in the MODEL section of a config file. Each model slot accepts either a
keyword (a model that is auto-downloaded and cached in ~/.local/share/mlgiddetect/) or a
path to a local .onnx file:
| keyword | model |
|---|---|
base |
default model for TYPE (the 2-class class-aware dino model, or the faster_rcnn model) |
ssl_pretrain |
SSL-pretrained 2-class dino model |
dino_old |
legacy single-class (91-class) dino model |
MODEL:
TYPE: 'dino' # 'dino' or 'faster_rcnn'
ONNX_BASE: base # model used on its own; a keyword or a path to an .onnx
ENSEMBLE_ENABLED: False # dino only: fuse ONNX_BASE + ONNX_ENSEMBLE (detection-level)
ONNX_ENSEMBLE: ssl_pretrain # second model, used only when ENSEMBLE_ENABLED is True
- Single model —
ENSEMBLE_ENABLED: FalserunsONNX_BASEalone. - Ensemble (dino only) —
ENSEMBLE_ENABLED: TruerunsONNX_BASE+ONNX_ENSEMBLEand fuses their detections with class-aware NMS. Both members must be 2-class ring/segment models, so keepPOSTPROCESSING.CLASSAWARE_NMS: True. - faster_rcnn — the ensemble is ignored; the single
ONNX_BASEmodel is always used.
To use the legacy model, set ONNX_BASE: dino_old, ENSEMBLE_ENABLED: False and
POSTPROCESSING.CLASSAWARE_NMS: False (the 91-class model needs single-class NMS).
Using the PyPI package
Use mlgidDETECT_tutorial.ipynb to get started.
GPU support
The pip package depends on the GPU build of ONNX Runtime, pinned per
Python version: onnxruntime-gpu==1.26.0 on Python 3.11+, 1.23.2 on
3.10 and 1.19.2 on 3.9 (the last releases with wheels for those
Pythons). All three are CUDA 12 builds (the same CUDA generation the
conda GPU environment ships); newer onnxruntime-gpu wheels (1.27+)
require the CUDA 13 runtime and load it at import time, which breaks
environments without it. If the GPU build is installed and CUDA is
available, it is automatically used for inference.
For CPU-only machines, replace it with the CPU build (never install
both at the same time, they share the same onnxruntime module and
overwrite each other):
pip uninstall -y onnxruntime-gpu
pip install onnxruntime
To use CUDA for preprocessing, use the install instructions for GPU support.
Metadata
Release files for mlgiddetect 0.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mlgiddetect-0.2.8.tar.gz | 36.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mlgiddetect-0.2.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 80.4 kB
Release files / mlgiddetect-0.2.8.tar.gz
| Download URL | mlgiddetect-0.2.8.tar.gz |
|---|---|
| Size | 36.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b11324dff1265a70206adb6296ba18f4c5857b2f3bf4725900b8fbc96408e998
|
|
BLAKE2b-256 checksum How to use checksums |
e8c965fa6f39c7e6f7e682b543786b2da709950c2a34b896961f5ac183f0248e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / mlgiddetect-0.2.8-py3-none-any.whl
| Download URL | mlgiddetect-0.2.8-py3-none-any.whl |
|---|---|
| Size | 44.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c337d8fb99a11479da85181fa96b4ae1742aecb3cb2df71d7f722d37bd8ca4a7
|
|
BLAKE2b-256 checksum How to use checksums |
afe97d3c4feafe6bbaaae88f8364349131539ebcdb268653790adacb7d7e5b21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|