vlkit.transforms package
Submodules
vlkit.transforms.compose module
- class vlkit.transforms.compose.RandomChoice(transforms, p=0.5, n=1, p_choice=None)[source]
Bases:
torch.nn.modules.module.Module
Random choose transforms
- Parameters
transforms (list) – list of transforms to be selected
n (int) – number of transforms will be selected in each step
p (list) – probabilities if each transforms being selected
- forward(x: PIL.Image.Image) PIL.Image.Image [source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
vlkit.transforms.interpolation module
vlkit.transforms.npr module
- class vlkit.transforms.npr.NPR(transform='stylization', sigma_s=60, sigma_r=0.001)[source]
Bases:
torch.nn.modules.module.Module
- Parameters
transform (str) – type of transformation, should be one of pencilsketch, stylization, detailEnhance or edgePreservingFilter.
sigma_s (int or list of ints) – see <https://docs.opencv.org/4.5.2/df/dac/group__photo__render.html>.
sigma_r (float or list of float) – see <https://docs.opencv.org/4.5.2/df/dac/group__photo__render.html>.
- forward(x: PIL.Image.Image) PIL.Image.Image [source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
vlkit.transforms.resize module
- class vlkit.transforms.resize.Resize(size, interpolation='bilinear', backend='pil')[source]
Bases:
torch.nn.modules.module.Module
Resize an image
- Parameters
size (int or tuple[int]) – the target size
interpolation (string, optional) – interpolation, can be random or a specific interpolation method.
backend (string, optional) – the backend used to resize. Should be one of cv2, pil or random.
- forward(img)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool
vlkit.transforms.transforms module
- class vlkit.transforms.transforms.CoordCrop(x1, y1, x2, y2)[source]
Bases:
torch.nn.modules.module.Module
- forward(img)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool