Skip to main content

Crate osf_rs

Crate osf_rs 

Source
Expand description

§osf-rs — OSF Sleep Foundation Model inference in Rust

Pure-Rust inference for the OSF (Open Sleep Foundation) model, built on Burn 0.20.

OSF is a Vision Transformer (ViT) trained with DINO+iBOT self-distillation on 166,500 hours of polysomnography data. It produces general-purpose representations from 12-channel PSG signals (EEG, EOG, EMG, ECG, respiratory).

§Quick start

use osf_rs::{OsfEncoder, ModelConfig};

let (encoder, _ms) = OsfEncoder::<B>::load_with_config(
    ModelConfig::default(),
    Path::new("osf_backbone.safetensors"),
    device,
)?;

let batch = osf_rs::build_batch::<B>(signal, 12, 1920, &device);
let emb = encoder.run_batch(&batch)?;
// emb.cls_emb: [768] — global epoch-level representation
// emb.patch_embs: [90 * 768] — local patch representations

Re-exports§

pub use encoder::OsfEncoder;
pub use config::ModelConfig;
pub use config::PSG_CHANNELS;
pub use config::NUM_PSG_CHANNELS;
pub use config::SAMPLE_RATE;
pub use config::EPOCH_SEC;
pub use config::EPOCH_SAMPLES;
pub use data::InputBatch;
pub use data::EpochEmbedding;
pub use data::EncodingResult;
pub use data::build_batch;
pub use data::channel_wise_normalize;

Modules§

config
data
encoder
model
weights