brails.utils.model_utils module

This module provides a utility class for computer vision models in BRAILS.

ModelUtils()

Utility class for computer vision models in BRAILS.

class brails.utils.model_utils.ModelUtils

Bases: object

Utility class for computer vision models in BRAILS.

This class provides static methods to ensure necessary model files are available locally, downloading them if needed. Intended for use in applications that rely on pre-trained model weights.

Methods:
get_model_path(model_path, default_filename, download_url,

model_description):

Ensures a model file exists locally or downloads it to a default location.

static get_model_path(model_path: str | None = None, default_filename: str | None = None, download_url: str | None = None, model_description: str = 'model') str

Ensure a model file is available locally, downloading it if needed.

Args:
model_path (str, optional):

Custom path to the model file. If provided, no download occurs.

default_filename (str, optional):

Filename to use if downloading the model.

download_url (str, optional):

URL to download the model if it doesn’t exist locally.

model_description (str):

Human-readable description of the model.

Returns:
str:

Path to the model file.

Raises:
ValueError:

If model_path is not provided and either default_filename or download_url is missing.