scxpand.pretrained.inference_api#
Internal inference API for pre-trained models.
This module provides internal functions for running inference with pre-trained models, handling automatic model downloading and loading. For external use, use scxpand.run_inference().
Functions
|
Internal function for running inference with pre-trained models. |
- scxpand.pretrained.inference_api.fetch_model_and_run_inference(model_name=None, model_url=None, data_path=None, adata=None, save_path=None, batch_size=None, num_workers=4, eval_row_inds=None)#
Internal function for running inference with pre-trained models.
This is an internal function that handles automatic model downloading, loading, and inference in a single call. Works with both file-based and in-memory data. For external use, use scxpand.run_inference() instead.
- Parameters:
model_name (
str|None(default:None)) – Name of pre-trained model from registry (alternative to model_url)model_url (
str|None(default:None)) – Direct URL to model ZIP file (alternative to model_name)data_path (
str|Path|None(default:None)) – Path to input data file (h5ad format) - alternative to adataadata (
AnnData|None(default:None)) – In-memory AnnData object - alternative to data_pathsave_path (
str|Path|None(default:None)) – Directory to save prediction results (optional)batch_size (
int|None(default:None)) – Batch size for inference (uses model default if None)num_workers (
int(default:4)) – Number of workers for data loadingeval_row_inds (default:
None) – Specific cell indices to evaluate (None for all cells)
- Returns:
Structured results containing predictions, metrics (if available), and model info
- Return type:
- Raises:
ValueError – If neither model_name nor model_doi provided, or neither data_path nor adata provided
FileNotFoundError – If data_path does not exist
Note
This is an internal function. For external use, use scxpand.run_inference() instead.