sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training package

Submodules

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment module

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.matrix(*rows, device=None)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.rotate2d(theta, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.rotate2d_inv(theta, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.rotate3d(v, theta, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.scale2d(sx, sy, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.scale2d_inv(sx, sy, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.scale3d(sx, sy, sz, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.translate2d(tx, ty, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.translate2d_inv(tx, ty, **kwargs)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.augment.translate3d(tx, ty, tz, **kwargs)[source]

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.canvas_loss module

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.dataset module

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.dataset.Dataset(name, raw_shape, original_resolution=None, max_size=None, use_labels=False, xflip=False, random_seed=0, transform=None)[source]

Bases: Dataset

_get_raw_labels()[source]
_load_raw_image(raw_idx)[source]
_load_raw_labels()[source]
close()[source]
get_details(idx)[source]
get_label(idx)[source]
property has_labels
property has_onehot_labels
property image_shape
property label_dim
property label_shape
property name
property num_channels
property original_resolution
print_info()[source]
property resolution
class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.dataset.EnsureChannelDimension[source]

Bases: object

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.dataset.ImageFolderDataset(path, resolution=None, resize_mode=None, regexp='.*', name=None, **super_kwargs)[source]

Bases: Dataset

static _file_ext(fname)[source]
_get_raw_image_chw_shape()[source]
_get_zipfile()[source]
_load_raw_image(raw_idx)[source]
_load_raw_labels()[source]
static _matches_regexp(fname, regexp)[source]
_open_file(fname)[source]
close()[source]
class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.dataset.PilToNp[source]

Bases: object

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss module

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss.DiceLoss[source]

Bases: Module

forward(source, target)[source]

Define 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.

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss.GeometryLoss(device, color_format='triad', internal_loss_dict={})[source]

Bases: object

The loss that wraps one or more segmentation losses between the “foreground” component and the geometry input.

_foreground_data(component, gen_data)[source]

Returns the foreground component of the Generator output. If color_format is triad, component can only take the value of uvs. If color_format is canvas, component can be either uvs or alpha, although we never use uvs here. @param component: a str, indicating the component to use for computing geom_loss. Valid values: “uvs” and “alpha” @param gen_data: a dict object that holds the output of the Generator. @return: a torch.Tensor of size [B, C, W, H]

_init_loss_dicts(component, internal_loss_dict)[source]
_validate_internal_dict(color_format, internal_loss_dict)[source]

Given two possible values for color_format - ‘triad’ and ‘canvas’ check if the corresponding weight of losses is provided. For ‘triad’, the user must provide geom_uvs_weights, and geom_alpha_weights is ignored. For canvas, the user must provide either geom_alpha_weights or geom_alpha_weights, or both. @param color_format @param internal_loss_dict: A dict object with keys geom_loss_types, geom_uvs_weights and geom_alpha_weights

geom_loss_types maps to a list of name string of losses; geom_uvs_weights and geom_alpha_weights maps to a list of floats.

compute(gen_data, geom_truth)[source]
class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss.IoULoss[source]

Bases: Module

forward(source: Tensor, target: Tensor)[source]

Define 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.

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss._MaskLoss(loss_types=['bce'])[source]

Bases: object

maskLoss makes use of the mask produced by color triad.

compute(foreground_data, geom_truth)[source]

@param foreground_data: torch.Tensor of shape [B, C, W, H] @param geom_truth: torch.Tensor of shape [B, 1, W, H] @return the loss value, of type torch scalar

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss.init_segmentation_loss(loss_type)[source]
sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss.logger = <Logger sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.geom_loss (NOTSET)>

Format of internal_loss_dict: {

geom_loss_weights: [], geom_uvs_types: [], geom_alpha_types: []

}

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss module

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss.Loss[source]

Bases: object

accumulate_gradients(phase, real_img, real_c, gen_z, gen_c, sync, gain)[source]
class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss.StyleGAN2Loss(device, G, D, augment_pipe=None, style_mixing_prob=0.9, r1_gamma=10, pl_batch_shrink=2, pl_decay=0.01, pl_weight=2, wasserstein=False)[source]

Bases: Loss

accumulate_gradients(phase, real_img, real_c, gen_z, gen_c, sync, gain)[source]
run_D(img, c, sync)[source]
run_G(z, c, sync)[source]

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss_modified module

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss_util module

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss_util.RGB2Gray[source]

Bases: Module

forward(img)[source]

Define 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.

class sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.loss_util.gradientLayer(edge_ksize=3)[source]

Bases: Module

forward(img)[source]

Define 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.

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.networks module

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.networks_modified module

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.training_loop module

sketchkit.stylization.brushstrokesengine.thirdparty.stylegan2_ada_pytorch.training.training_loop_modified module

Module contents