sketchkit.image2sketch.swiftsketch.model package¶
Submodules¶
sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model module¶
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.CLIPMiddle(image_features_dim, latent_dim)[source]¶
Bases:
Module- forward(features)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.CLIPMiddle_ca(image_features_dim, latent_dim)[source]¶
Bases:
Module- forward(features)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.InputProcess(input_feats_dim, latent_dim)[source]¶
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.OutputProcess(output_feats_dim, latent_dim, ncpoints, nfeats, normalize_output, scaling_factor)[source]¶
Bases:
Module- forward(output)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.PositionalEncoding(d_model, dropout=0.1, max_len=5000)[source]¶
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.SwiftSketch(image_features_type='CLIPMiddle_layer4', latent_dim=256, ff_size=1024, num_layers=8, num_heads=4, dropout=0.1, activation='gelu', normalize_model_output=0, cond_mode='no_cond', cond_mask_prob=0, arch='trans_dec', emb_trans_dec=0, scaling_factor=2)[source]¶
Bases:
Module- forward(x, timesteps, image_features=None, uncond=False, scale=None)[source]¶
x: [batch_size, nstrokes, ncpoints, nfeats], denoted x_t in the paper timesteps: [batch_size] (int)
- parameters()[source]¶
Return an iterator over module parameters.
This is typically passed to an optimizer.
- Parameters:
recurse (bool) – if True, then yields parameters of this module and all submodules. Otherwise, yields only parameters that are direct members of this module.
- Yields:
Parameter – module parameter
Example:
>>> # xdoctest: +SKIP("undefined vars") >>> for param in model.parameters(): >>> print(type(param), param.size()) <class 'torch.Tensor'> (20L,) <class 'torch.Tensor'> (20L, 1L, 5L, 5L)
- class sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model.TimestepEmbedder(latent_dim, sequence_pos_encoder)[source]¶
Bases:
Module- forward(timesteps)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
sketchkit.image2sketch.swiftsketch.model.cfg_sampler module¶
- class sketchkit.image2sketch.swiftsketch.model.cfg_sampler.ClassifierFreeSampleModel(model)[source]¶
Bases:
Module- forward(x, timesteps, image_features, scale)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
sketchkit.image2sketch.swiftsketch.model.image_features_models module¶
- class sketchkit.image2sketch.swiftsketch.model.image_features_models.CLIPMidlleFeutures(device, layer)[source]¶
Bases:
Module- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class sketchkit.image2sketch.swiftsketch.model.image_features_models.DINO2Feutures(device)[source]¶
Bases:
Module- forward(image)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
Module contents¶
Neural network models used by the SwiftSketch backend.