trw.transforms.cutout_function
¶
Module Contents¶
Classes¶
Base class for protocol classes. Protocol classes are defined as: |
Functions¶
|
Replace all image as a constant value |
|
Replace the image content as a constant value |
|
Return a random size within the specified bounds. |
|
Remove a part of the image randomly |
- trw.transforms.cutout_function.cutout_value_fn_constant(image: trw.basic_typing.Tensor, value: trw.basic_typing.Numeric) None ¶
Replace all image as a constant value
- trw.transforms.cutout_function.cutout_random_ui8_torch(image: torch.Tensor, min_value: int = 0, max_value: int = 255) None ¶
Replace the image content as a constant value
- trw.transforms.cutout_function.cutout_random_size(min_size: Sequence[int], max_size: Sequence[int]) List[int] ¶
Return a random size within the specified bounds.
- Parameters
min_size – a sequence representing the min size to be generated
max_size – a sequence representing the max size (inclusive) to be generated
- Returns
a tuple representing the size
- class trw.transforms.cutout_function.CutOutType¶
Bases:
typing_extensions.Protocol
Base class for protocol classes. Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing_extensions.runtime act as simple-minded runtime protocol that checks only the presence of given attributes, ignoring their type signatures.
Protocol classes can be generic, they are defined as:
class GenProto(Protocol[T]): def meth(self) -> T: ...
- __call__(self, image: trw.basic_typing.TensorNCX) None ¶
- trw.transforms.cutout_function.cutout(image: trw.basic_typing.TensorNCX, cutout_size: Union[trw.basic_typing.ShapeCX, Callable[[], trw.basic_typing.ShapeCX]], cutout_value_fn: CutOutType) None ¶
Remove a part of the image randomly
- Parameters
image – a
numpy.ndarray
ortorch.Tensor
n-dimensional array. Samples are stored on axis 0cutout_size – the cutout_size of the regions to be occluded or a callable function taking no argument and returning a tuple representing the shape of the region to be occluded (without the
N
component)cutout_value_fn – the function value used for occlusion. Must take as argument image and modify directly the image
- Returns
None