physioex.models.load_from_pretrained#
- physioex.models.load_from_pretrained(name, device='cpu', verbose=False, repo_id=None)[source]#
Load a pretrained model, downloading the weights if needed.
If
nameis a registered third-party model (seeTHIRD_PARTY_PRETRAINED— wav2sleep, wav2sleep-eog, sleepppgnet-replica,jones-ecg-*) andrepo_idis not set, the checkpoint is downloaded to the foundation-model cache ($PHYSIOEX_CACHE_DIR/v1/foundation_models/<name>/) and the model is built with the authors’from_originalfactory. Licenses that are not MIT/Apache/BSD are always logged as a warning.Otherwise the 4rooms/physioex behaviour applies: the model class and constructor kwargs are read from the
config.jsonstored in the HF repo (e.g."seqsleepnet-huy").- Parameters:
name (str) – Model identifier — a third-party registry name or a sub-folder in the HF repo.
device (str) – Device to load the model onto (default
"cpu").verbose (bool) – If True, print model info; for third-party models also the reference, license, classes and expected input.
repo_id (str) – Override the HF repo for the 4rooms-style load.
- Returns:
The pretrained
nn.Modulein eval mode on device.- Return type:
Example:
from physioex.models import load_from_pretrained model = load_from_pretrained("seqsleepnet-huy", verbose=True) model = load_from_pretrained("wav2sleep", verbose=True)