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.interpolation.get_interp(interpolation='bilinear', backend='pil')[source]
vlkit.transforms.interpolation.get_random_interp(backend='pil')[source]

vlkit.transforms.npr module

Non-Photorealistic Rendering

class vlkit.transforms.npr.NPR(transform='stylization', sigma_s=60, sigma_r=0.001)[source]

Bases: torch.nn.modules.module.Module

Non-Photorealistic Rendering

Parameters
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.resize.format_size(size)[source]
vlkit.transforms.resize.resize(im, size, interpolation='bilinear', backend='pil')[source]

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

Module contents