Skip to content

unienv_data.storages.image_storage

Classes:

Name Description
ImageStorage

ImageStorage

ImageStorage(
    single_instance_space: BoxSpace[BArrayType, BDeviceType, BDtypeType, BRNGType],
    format: str,
    quality: int,
    cache_filename: Union[str, PathLike],
    mutable: bool = True,
    capacity: Optional[int] = None,
    length: int = 0,
)

Bases: ListStorageBase[BArrayType, BArrayType, BDeviceType, BDtypeType, BRNGType]

Methods:

Name Description
create
load_from
get_from_file
set_to_file
dumps
close
get_segments
mark_segment_start
append

Append one structured sample to the storage.

mark_segment_end
abort_segment
extend_length
shrink_length
get
set
open_segment_writer

A writer that builds one segment of this storage off to the side; see SegmentWriter.

clear
get_single
set_single

Attributes:

Name Type Description
single_file_ext
format
quality
capacity
cache_filename Union[str, PathLike]
is_multiprocessing_safe bool
is_mutable
backend ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]
device Optional[BDeviceType]
single_instance_space
has_open_segment bool
pending_segment_length int
file_ext
length

single_file_ext class-attribute instance-attribute

single_file_ext = None

format instance-attribute

format = format

quality instance-attribute

quality = quality

capacity instance-attribute

capacity = capacity

cache_filename property

cache_filename: Union[str, PathLike]

is_multiprocessing_safe property

is_multiprocessing_safe: bool

is_mutable instance-attribute

is_mutable = mutable

backend property

backend: ComputeBackend[BArrayType, BDeviceType, BDtypeType, BRNGType]

device property

device: Optional[BDeviceType]

single_instance_space instance-attribute

single_instance_space = single_instance_space

has_open_segment property

has_open_segment: bool

pending_segment_length property

pending_segment_length: int

file_ext instance-attribute

file_ext = file_ext

length instance-attribute

length = length if capacity is None else capacity

create classmethod

create(
    single_instance_space: BoxSpace[BArrayType, BDeviceType, BDtypeType, BRNGType],
    *args,
    format: str = "JPEG",
    quality: int = 75,
    capacity: Optional[int] = None,
    cache_path: Optional[str] = None,
    multiprocessing: bool = False,
    **kwargs,
) -> ImageStorage[BArrayType, BDeviceType, BDtypeType, BRNGType]

load_from classmethod

load_from(
    path: Union[str, PathLike],
    single_instance_space: BoxSpace[BArrayType, BDeviceType, BDtypeType, BRNGType],
    *,
    capacity: Optional[int] = None,
    read_only: bool = True,
    multiprocessing: bool = False,
    **kwargs,
) -> ImageStorage[BArrayType, BDeviceType, BDtypeType, BRNGType]

get_from_file

get_from_file(filename: str) -> BArrayType

set_to_file

set_to_file(filename: str, value: BArrayType)

dumps

dumps(path)

close

close()

get_segments

get_segments()

mark_segment_start

mark_segment_start(start_index: int) -> None

append

append(value) -> None

Append one structured sample to the storage.

Appended values may be immediately visible or only visible after mark_segment_end() depending on the storage implementation.

mark_segment_end

mark_segment_end() -> None

abort_segment

abort_segment() -> None

extend_length

extend_length(length)

shrink_length

shrink_length(length)

get

get(index)

set

set(index, value)

open_segment_writer

open_segment_writer() -> SegmentWriter

A writer that builds one segment of this storage off to the side; see SegmentWriter. Unlike mark_segment_start() / append(), any number of writers can be open at a time. The default keeps the samples in memory until the commit; storages override it to stream instead.

clear

clear()

get_single

get_single(index: int) -> BatchT

set_single

set_single(index: int, value: BArrayType)