API Reference#
Root#
- uform.get_checkpoint(model_name: str, modalities: Tuple[str, Modality], token: Optional[str] = None, format: Literal['.pt', '.onnx'] = '.pt') Tuple[str, Dict[Modality, str], Optional[str]]#
- Downloads a model checkpoint from the Hugging Face Hub. - Parameters:
- model_name – The name of the model to download, like unum-cloud/uform3-image-text-english-small 
- token – The Hugging Face API token, if required 
- modalities – The modalities to download, like (“text_encoder”, “image_encoder”) 
- format – The format of the model checkpoint, either .pt or .onnx 
 
- Returns:
- A tuple of the config path, dictionary of paths to different modalities, and tokenizer path 
 
- uform.get_model(model_name: str, *, device: Literal['cpu', 'cuda'] = 'cpu', backend: Literal['onnx', 'torch'] = 'onnx', modalities: Optional[Tuple[str, Modality]] = None, token: Optional[str] = None) Tuple[Dict[Modality, Callable], Dict]#
- Fetches a model and its processors from the Hugging Face Hub, using either the ONNX or Torch backend. - Parameters:
- model_name – The identifier of the model on the Hugging Face Hub. 
- device – The device to load the model onto (‘cpu’ or ‘cuda’). 
- backend – The backend framework to use (‘onnx’ or ‘torch’). 
- modalities – A tuple specifying the types of model components to fetch. 
- token – Optional API token for authenticated access to the model. 
 
- Returns:
- A tuple containing dictionaries for processors and models keyed by their respective modalities. 
 
- uform.get_model_onnx(model_name: str, *, device: Literal['cpu', 'cuda'] = 'cpu', token: Optional[str] = None, modalities: Optional[Tuple[str]] = None)#
- Fetches and constructs an ONNX model with its processors based on provided modalities. - Parameters:
- model_name – The identifier of the model on the Hugging Face Hub. 
- device – The device on which the model will operate (‘cpu’ or ‘cuda’). 
- token – Optional API token for authenticated access to the model. 
- modalities – A tuple specifying the types of model components to fetch (e.g., text encoder). 
 
- Returns:
- A tuple containing dictionaries for processors and models keyed by their respective modalities. 
 
- uform.get_model_torch(model_name: str, *, token: Optional[str] = None, device: Literal['cpu', 'cuda'] = 'cpu', modalities: Optional[Tuple[Union[str, Modality]]] = None) Tuple[Dict[Modality, Callable], Dict]#
- Fetches and constructs a PyTorch model with its processors based on provided modalities. - Parameters:
- model_name – The identifier of the model on the Hugging Face Hub. 
- token – Optional API token for authenticated access to the model. 
- device – The device to load the model onto (‘cpu’ or ‘cuda’). 
- modalities – A tuple specifying the types of model components to fetch (e.g., text encoder). 
 
- Returns:
- A tuple containing dictionaries for processors and models keyed by their respective modalities.