sketchkit.image2sketch.swiftsketch package¶
Subpackages¶
- sketchkit.image2sketch.swiftsketch.diffusion package
- Submodules
- sketchkit.image2sketch.swiftsketch.diffusion.Loss_computation module
- sketchkit.image2sketch.swiftsketch.diffusion.fp16_util module
MixedPrecisionTrainerMixedPrecisionTrainer._compute_norms()MixedPrecisionTrainer._optimize_fp16()MixedPrecisionTrainer._optimize_normal()MixedPrecisionTrainer.backward()MixedPrecisionTrainer.master_params_to_state_dict()MixedPrecisionTrainer.optimize()MixedPrecisionTrainer.state_dict_to_master_params()MixedPrecisionTrainer.zero_grad()
check_overflow()convert_module_to_f16()convert_module_to_f32()get_param_groups_and_shapes()make_master_params()master_params_to_model_params()master_params_to_state_dict()model_grads_to_master_grads()param_grad_or_zeros()state_dict_to_master_params()unflatten_master_params()zero_grad()zero_master_grads()
- sketchkit.image2sketch.swiftsketch.diffusion.gaussian_diffusion module
GaussianDiffusionGaussianDiffusion._predict_eps_from_xstart()GaussianDiffusion._predict_xstart_from_eps()GaussianDiffusion._predict_xstart_from_xprev()GaussianDiffusion._scale_timesteps()GaussianDiffusion.p_mean_variance()GaussianDiffusion.p_sample()GaussianDiffusion.p_sample_loop()GaussianDiffusion.p_sample_loop_progressive()GaussianDiffusion.plot_forward_pass_with_predicted_x0()GaussianDiffusion.q_mean_variance()GaussianDiffusion.q_posterior_mean_variance()GaussianDiffusion.q_sample()GaussianDiffusion.training_losses()
ModelMeanTypeModelVarType_extract_into_tensor()betas_for_alpha_bar()get_named_beta_schedule()
- sketchkit.image2sketch.swiftsketch.diffusion.logger module
CSVOutputFormatHumanOutputFormatJSONOutputFormatKVWriterLoggerSeqWriterTensorBoardOutputFormat_configure_default_logger()configure()debug()dump_tabular()dumpkvs()error()get_current()get_dir()get_rank_without_mpi_import()getkvs()info()log()logkv()logkv_mean()logkvs()make_output_format()mpi_weighted_mean()profile()profile_kv()record_tabular()reset()scoped_configure()set_comm()set_level()warn()
- sketchkit.image2sketch.swiftsketch.diffusion.resample module
- sketchkit.image2sketch.swiftsketch.diffusion.respace module
- Module contents
- sketchkit.image2sketch.swiftsketch.model package
- Submodules
- sketchkit.image2sketch.swiftsketch.model.SwiftSketch_model module
- sketchkit.image2sketch.swiftsketch.model.cfg_sampler module
- sketchkit.image2sketch.swiftsketch.model.image_features_models module
- Module contents
- sketchkit.image2sketch.swiftsketch.refine_model package
- sketchkit.image2sketch.swiftsketch.utils package
- Submodules
- sketchkit.image2sketch.swiftsketch.utils.dist_util module
- sketchkit.image2sketch.swiftsketch.utils.fixseed module
- sketchkit.image2sketch.swiftsketch.utils.get_data module
- sketchkit.image2sketch.swiftsketch.utils.get_features module
- sketchkit.image2sketch.swiftsketch.utils.model_util module
- sketchkit.image2sketch.swiftsketch.utils.parser_util module
add_base_options()add_data_options()add_diffusion_options()add_generate_options()add_loss_options()add_model_options()add_sketch_options()add_training_options()add_wandb_options()generate_args()get_args_per_group_name()get_cond_mode()get_model_path_from_args()get_wandb_name()parse_and_load_from_model()train_args()
- sketchkit.image2sketch.swiftsketch.utils.sketch_utils module
calculate_highest_points()calculate_length()convert_image_to_pil()create_masked_image()denormalize_points()extract_control_points_from_svg()fix_image_scale()generate_svg_content()get_features_dim()get_mask()get_thick_contour_tensor()load_compressed_npz()load_entry()log_diffusion_process_to_wandb()log_grid()log_grid_images_list()log_grid_model_sketches()log_grid_model_sketches_all()log_grid_test()log_model_prediction()log_refine_model_prediction()parse_svg_size()plot_row()rander_image_from_points()render_image_from_norm_points()render_image_from_norm_points_svg()render_paths()save_key()save_svg_from_points()sort_by_contour()sort_by_contour_and_attn()sort_strokes()svg_from_points()svg_to_pil()
- Module contents
Submodules¶
sketchkit.image2sketch.swiftsketch.generate module¶
SwiftSketch programmatic API.
This module exposes the SwiftSketchModel selected by
SketchGenerator(method="SwiftSketch"). The implementation wraps the original
SwiftSketch diffusion pipeline while providing a higher level API that handles
checkpoint management and preprocessing automatically.
- class sketchkit.image2sketch.swiftsketch.generate.SwiftSketchModel(*, device: str | device | None = None, use_refine: bool = True, guidance_param: float = 2.5, fix_scale: bool = True, checkpoint_dir: str | PathLike | None = None, auto_download: bool = True, mask_model_factory: Callable[[device], Module] | None = None, feature_extractor_factory: Callable[[device, str], Module] | None = None, diffusion_factory: Callable[[SimpleNamespace], Tuple[Module, object]] | None = None, refine_model_factory: Callable[[SimpleNamespace], Module] | None = None)[source]¶
Bases:
objectHigh level wrapper around the SwiftSketch diffusion pipeline.
- static _control_points_to_sketch(control_points: Tensor, canvas_size: Tuple[int, int]) Sketch[source]¶
- static _resolve_device(device: str | device | None) device[source]¶
Determine which device SwiftSketch should run on.
By default, a CUDA-capable GPU is required. Users can override the selection via the
SKETCHKIT_SWIFTSKETCH_DEVICEenvironment variable or by explicitly passing adeviceargument. When neither is supplied and CUDA is unavailable, the model refuses to run unless theSKETCHKIT_ALLOW_CPU_FALLBACKenvironment variable is set to"1". This makes it possible to exercise the pipeline on CPU for testing while keeping the production default focused on GPU runtimes.
- property checkpoint_dir: Path¶
- property device: device¶
- generate(image: Image | ndarray | str | PathLike | Sequence[Image | ndarray | str | PathLike], size: int | Tuple[int, int] | None = None) Sketch | List[Sketch][source]¶
Generate sketches for the provided image(s).
- generate_batch(images: Sequence[Image | ndarray | str | PathLike], *, size: int | Tuple[int, int] | None = None) List[Sketch][source]¶
- property model_archive_path: Path¶
- property refine_archive_path: Path¶
Module contents¶
SwiftSketch image-to-vector-sketch backend.
- class sketchkit.image2sketch.swiftsketch.SwiftSketchModel(*, device: str | device | None = None, use_refine: bool = True, guidance_param: float = 2.5, fix_scale: bool = True, checkpoint_dir: str | PathLike | None = None, auto_download: bool = True, mask_model_factory: Callable[[device], Module] | None = None, feature_extractor_factory: Callable[[device, str], Module] | None = None, diffusion_factory: Callable[[SimpleNamespace], Tuple[Module, object]] | None = None, refine_model_factory: Callable[[SimpleNamespace], Module] | None = None)[source]¶
Bases:
objectHigh level wrapper around the SwiftSketch diffusion pipeline.
- static _control_points_to_sketch(control_points: Tensor, canvas_size: Tuple[int, int]) Sketch[source]¶
- static _resolve_device(device: str | device | None) device[source]¶
Determine which device SwiftSketch should run on.
By default, a CUDA-capable GPU is required. Users can override the selection via the
SKETCHKIT_SWIFTSKETCH_DEVICEenvironment variable or by explicitly passing adeviceargument. When neither is supplied and CUDA is unavailable, the model refuses to run unless theSKETCHKIT_ALLOW_CPU_FALLBACKenvironment variable is set to"1". This makes it possible to exercise the pipeline on CPU for testing while keeping the production default focused on GPU runtimes.
- property checkpoint_dir: Path¶
- property device: device¶
- generate(image: Image | ndarray | str | PathLike | Sequence[Image | ndarray | str | PathLike], size: int | Tuple[int, int] | None = None) Sketch | List[Sketch][source]¶
Generate sketches for the provided image(s).
- generate_batch(images: Sequence[Image | ndarray | str | PathLike], *, size: int | Tuple[int, int] | None = None) List[Sketch][source]¶
- property model_archive_path: Path¶
- property refine_archive_path: Path¶