SafeTensorsReader#
- class vision_architectures.image_readers.safetensors_reader.SafetensorsReader(image_key='images', spacing_key='spacing', other_keys=None, add_channel_dim=True, dtype=torch.float32)[source]#
Bases:
ImageReader
- __init__(image_key='images', spacing_key='spacing', other_keys=None, add_channel_dim=True, dtype=torch.float32)[source]#
- verify_suffix(filename)[source]#
Verify whether the specified filename is supported by the current reader. This method should return True if the reader is able to read the format suggested by the filename.
- Parameters:
filename – file name or a list of file names to read. if a list of files, verify all the suffixes.
- read(filepath)[source]#
Read image data from specified file or files. Note that it returns a data object or a sequence of data objects.
- Parameters:
data – file name or a list of file names to read.
kwargs – additional args for actual read API of 3rd party libs.
- Return type:
dict
[str
,Union
[Tensor
,Any
]]
- get_data(datapoint)[source]#
Extract data array and metadata from loaded image and return them. This function must return two objects, the first is a numpy array of image data, the second is a dictionary of metadata.
- Parameters:
img – an image object loaded from an image file or a list of image objects.