tk_r_em 2.0.0
Complete rewrite of the inference engine from TensorFlow/Keras to ONNX Runtime. The six pre-trained CGRDN models are now shipped as .onnx files and run on CPU, NVIDIA GPU, or DirectML without any TensorFlow dependency.
What's new
- ONNX Runtime backend — no TensorFlow/Keras dependency at runtime. Three install variants:
[cpu],[gpu](NVIDIA CUDA),[directml](Windows DX12). predict_patch_based— seamless tiled inference for images larger than GPU memory, blended with a Butterworth window.- Streamlit web app (
app.py) — drag-and-drop browser interface for single-image restoration. - EMD file support — Velox/Thermo Fisher
.emdfiles can now be loaded in both the Python API and the Streamlit web app viarsciio.emd. - Four example scripts — simulated data, experimental single/batch/patch-based inference.
- Two Jupyter notebooks — introduction notebook and a full workshop tutorial with inline outputs.
pyproject.tomlwith[cpu],[gpu],[directml], and[notebook]extras.- Licence: GPL-3.0-only — all SPDX headers,
pyproject.toml, andversion.pyconsistently declare GPL-3.0-only. - Fail-loud error handling — removed silent exception swallowing in ONNX DLL preloading and model discovery; invalid user input now shows warnings instead of silently falling back.
- Standardised file headers — all
.pyfiles have the copyright/SPDX/module-docstring block.
Installation
git clone https://github.com/Ivanlh20/tk_r_em.git
cd tk_r_em
pip install -e ".[cpu]" # CPU (portable)
# pip install -e ".[gpu]" # NVIDIA CUDA
# pip install -e ".[directml]" # Windows DX12Models
Six pre-trained CGRDN networks (7.04 M parameters each), one per modality x resolution:
| Tag | Modality | Resolution |
|---|---|---|
sfr_hrsem |
SEM | High |
sfr_lrsem |
SEM | Low |
sfr_hrstem |
STEM | High |
sfr_lrstem |
STEM | Low |
sfr_hrtem |
TEM | High |
sfr_lrtem |
TEM | Low |
Reference
Lobato, I., Friedrich, T., Van Aert, S. Deep convolutional neural networks to restore single-shot electron microscopy images. npj Computational Materials 10, 10 (2024). doi:10.1038/s41524-023-01188-0
v1 (TensorFlow/Keras) history is preserved via the v1.0.5 tag.