multimeditron.dataset.loader.image package

Submodules

multimeditron.dataset.loader.image.bytes module

class multimeditron.dataset.loader.image.bytes.RawImageLoader

Bases: BaseModalityLoader

Loader for raw image bytes. Expects the sample dictionary to have a “value” key containing a dictionary with a “bytes” key holding the raw image bytes. Example:

loader = RawImageLoader()
sample = {"value": {"bytes": b'...'}, "type": "image"}
image = loader.load(sample)
# image is a PIL Image object
load(sample: Dict[str, Any]) Image

Load an image from raw bytes.

Parameters:

sample (Dict[str, Any]) – A dictionary containing at least the “value” key with a dictionary that has a “bytes” key holding the raw image bytes.

Returns:

The loaded image as a PIL Image object.

Return type:

PIL.Image.Image

name: str = 'raw-image'

multimeditron.dataset.loader.image.fs module

class multimeditron.dataset.loader.image.fs.FileSystemImageLoader(base_path: str | Path)

Bases: BaseModalityLoader

Loader for image files from the filesystem. Expects the sample dictionary to have a “value” key containing the relative path to the image file. The base_path parameter specifies the root directory where images are stored. Example:

loader = FileSystemImageLoader(base_path="/path/to/images")
sample = {"value": "image1.jpg", "type": "image"}
image = loader.load(sample)
# image is a PIL Image object
load(sample: Dict[str, Any]) Image

Load an image from the filesystem. :param sample: A dictionary containing at least the “value” key with the relative path to the image file. :type sample: Dict[str, Any]

Returns:

The loaded image as a PIL Image object.

Return type:

PIL.Image.Image

name: str = 'fs-image'

Module contents