Skip to content

Latest commit

 

History

History
66 lines (37 loc) · 2.83 KB

README.md

File metadata and controls

66 lines (37 loc) · 2.83 KB

sims-web

Run SIMS in the browser using h5wasm to read local AnnData (.h5ad) files and ONNX to run the model.

Opens an h5ad in the browser and runs a selected SIMs model and displays predictions.

You can view the default ONNX model via netron

Alt text

Developing

Export a SIMS checkpoint to an onnx file and list of genes. Note this assumes you have the SIMS repo as a peer to this one so it can load the model definition.

python scripts/sims-to-onnx.py models/default.ckpt

Check the core model for compatibility with onnx

python -m onnxruntime.tools.check_onnx_model_mobile_usability models/default.onnx

Serve the web app and models locally

make serve

Memory Requirements

worker.js uses h5wasm slice() to read data from the cell by gene matrix (i.e. X). As these data on disk are typically stored row major (i.e. all data for a cell is contiguous) we can process the sample incrementally keeping memory requirements to a minimum. Reading cell by cell from a 5.3G h5ad file consumed just under 30M of browser memory. YMMV.

Performance

Processing a test sample with 2638 cells took 67 seconds in the browser vs. 34 seconds in python on the same machine.

Leveraging a GPU

ONNX Web Runtime does have support for GPUs, but unfortunately they don't support all operators yet. Specifically TopK is not supported

References

Open Neural Network Exchange (ONNX)

ONNX Runtime Web (WASM Backend)

ONNX Runtime Web Platform Functionality Details

ONNX Runtime Javascript Examples

Netron ONNX Graph Display Website

Graphical ONNX Editor Classify images in a web application with ONNX Runtime Web

h5wasm

anndata/h5ad file structure and on disk format

SIMS Streamlit App and Source

TabNet Model for attentive tabular learning