sketchkit.vectorization.DeepVecSIG24 package

Submodules

sketchkit.vectorization.DeepVecSIG24.DeepVecSIG24 module

class sketchkit.vectorization.DeepVecSIG24.DeepVecSIG24.DeepVecSIG24(device: str = 'cuda')[source]

Bases: object

A class for image vectorization using the method of paper “Deep Sketch Vectorization via Implicit Surface Extraction” in SIGGRAPH 2024.

device

The device that is used.

Type:

str

_D(t)[source]
_download_models()[source]

Download the pretrained models

_load_checkpoint_ndc(filepath)[source]

Loads model from a checkpoint we will need the distance threshold to accruately recover the UDF for the next NDC model

_load_checkpoint_udf(filepath)[source]

Loads model from a checkpoint we will need the distance threshold to accruately recover the UDF for the next NDC model

_load_img(img_np, device, resize=False, resize_to=1024)[source]
_load_model(device)[source]
_paths_to_Sketch(paths)[source]
_pre_svg(net, udf, gsize)[source]
_pre_udf(net, img)[source]
_predict_SVG(udf_topo_pre, model_ndc, args_udf, args_ndc, refine=True)[source]
_predict_UDF(img, img_np, model_udf, usm_thr=0.5)[source]
_simplify_SVG(path_to_svg, keypt_pre_dict, rdp_simplify=False, epsilon=0.4, skip_len=4)[source]
_vis_stroke(strokes, canvas_size, save_path)[source]
run(image_array: ndarray, image_folder: str = './', out_folder: str = 'svg') Sketch[source]

Vectorize the input raster image.

Parameters:
  • image_array (numpy.ndarray) – input raster image in shape (H, W), with values in [0, 255].

  • image_folder (str, optional) – the folder of the input raster image.

  • out_folder (str, optional) – an output folder to store the output svg file.

Returns:

a Sketch instance.

Return type:

sketch (Sketch)

sketchkit.vectorization.DeepVecSIG24.DeepVecSIG24.safe_torch_load(path: str, **kwargs)[source]

Safely loads a PyTorch checkpoint with weights_only=True.

PyTorch 2.6+ defaults to weights_only=True, which blocks some globals in checkpoints (e.g., argparse.Namespace, types.SimpleNamespace). This function keeps weights_only=True but allowlists common ones. Falls back gracefully for older torch versions.

Parameters:
  • path – Path to the checkpoint file.

  • **kwargs – Additional keyword arguments to pass to torch.load.

Returns:

The loaded checkpoint.

Module contents

class sketchkit.vectorization.DeepVecSIG24.DeepVecSIG24(device: str = 'cuda')[source]

Bases: object

A class for image vectorization using the method of paper “Deep Sketch Vectorization via Implicit Surface Extraction” in SIGGRAPH 2024.

device

The device that is used.

Type:

str

_D(t)[source]
_download_models()[source]

Download the pretrained models

_load_checkpoint_ndc(filepath)[source]

Loads model from a checkpoint we will need the distance threshold to accruately recover the UDF for the next NDC model

_load_checkpoint_udf(filepath)[source]

Loads model from a checkpoint we will need the distance threshold to accruately recover the UDF for the next NDC model

_load_img(img_np, device, resize=False, resize_to=1024)[source]
_load_model(device)[source]
_paths_to_Sketch(paths)[source]
_pre_svg(net, udf, gsize)[source]
_pre_udf(net, img)[source]
_predict_SVG(udf_topo_pre, model_ndc, args_udf, args_ndc, refine=True)[source]
_predict_UDF(img, img_np, model_udf, usm_thr=0.5)[source]
_simplify_SVG(path_to_svg, keypt_pre_dict, rdp_simplify=False, epsilon=0.4, skip_len=4)[source]
_vis_stroke(strokes, canvas_size, save_path)[source]
run(image_array: ndarray, image_folder: str = './', out_folder: str = 'svg') Sketch[source]

Vectorize the input raster image.

Parameters:
  • image_array (numpy.ndarray) – input raster image in shape (H, W), with values in [0, 255].

  • image_folder (str, optional) – the folder of the input raster image.

  • out_folder (str, optional) – an output folder to store the output svg file.

Returns:

a Sketch instance.

Return type:

sketch (Sketch)