Skip to main content

SketchKit

SketchKit is a Python toolkit for loading, representing, processing, and rendering digital sketches. It is designed for researchers studying sketch data and developers building sketch-based applications, with unified APIs for datasets, vectorization, stroke ordering, image generation, colorization, animation, and 3D modeling.

Documentation · Getting Started · API Reference

SketchKit Examples

Why SketchKit?

  • Unified sketch representation — work with different datasets through the same Sketch, Path, Curve, and Point hierarchy.
  • 14 built-in datasets — load popular sketch datasets on demand and filter samples through pandas metadata.
  • Composable sketch workflows — connect compatible datasets, processing methods, and renderers through a shared representation.
  • 2D and 3D rendering — rasterize vector strokes, render expressive brush strokes, or project 3D sketches from multiple camera views.
  • Research methods behind simple interfaces — use task-level APIs such as Vectorizer, Orderer, Colorizer, and Modeler.

Installation

SketchKit requires Python 3.12 or later and uses uv for dependency and environment management.

Install uv on macOS or Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

On Windows PowerShell:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Clone or download this repository, then install the project environment:

git clone https://github.com/CISLab-HKUST/SketchKit.git
cd SketchKit
uv sync

macOS distribution wheels

The macOS wheel includes Cairo and the native RTSC renderer. Installing a matching wheel does not require Homebrew, a separate Cairo installation, or DYLD_* settings. The usual Python dependencies are installed by pip. Choose a wheel matching your Python version, Mac architecture, and macOS version.

Building from source on macOS

The following native dependencies are needed on the build machine, including for editable installs with uv sync or pip install -e .:

If brew is not available, install Homebrew first and follow the installer's instructions to add it to your shell environment. Then run:

brew install pkgconf glfw glew

Build a wheel for distribution:

DIFFVG_CUDA=0 uv build --wheel --python 3.12

Wheel builds on macOS, Linux, and Windows use third_party/cairo/build.py to compile the pinned Cairo source and bundle it alongside Teddy, DiffVG, and RTSC in sketchkit/_native/. The first build downloads source archives. Subsequent builds reuse those archives and recompile. SKETCHKIT_CAIRO_SOURCE_CACHE can point to a prepopulated source cache. Linux Cairo builds also need gperf and pkg-config on the build machine. Windows Cairo builds use the Visual Studio C/C++ toolchain. Editable builds also prepare this private directory in the source tree. These generated files are ignored by Git. RTSC uses a hidden OpenGL window and requires a working graphical session. NPRRenderer reports native rendering errors when used.

Verify the installation:

uv run python -c "import sketchkit; print('SketchKit is ready')"

Troubleshooting: Cairo not found on macOS

This section applies to older wheels or source trees whose native runtime has not been built. Current macOS wheels load their private Cairo automatically.

If importing SketchKit raises OSError: no library called "cairo-2" was found or reports that libcairo.2.dylib cannot be loaded, first ensure that brew install cairo has completed successfully. Some Python/Homebrew configurations do not automatically search Homebrew's library directory. Only if the error persists, provide that directory explicitly:

export DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix)/lib${DYLD_FALLBACK_LIBRARY_PATH:+:$DYLD_FALLBACK_LIBRARY_PATH}"
uv run python -c "import sketchkit; print('SketchKit is ready')"

The export applies to the current terminal and commands started from it. To keep the setting for new zsh terminals, add the export line to ~/.zshrc and run source ~/.zshrc in the current terminal.

macOS can strip inherited DYLD_* variables when launching some uv builds. If the export does not resolve the error, set the variable after uv starts:

uv run --no-sync env \
  DYLD_FALLBACK_LIBRARY_PATH="$(brew --prefix)/lib${DYLD_FALLBACK_LIBRARY_PATH:+:$DYLD_FALLBACK_LIBRARY_PATH}" \
  python -c "import sketchkit; print('SketchKit is ready')"

This fallback applies only to the command. To run a script with it, replace -c "import sketchkit; print('SketchKit is ready')" with its filename. Re-running uv sync alone will not install Cairo or configure its search path.

Quick Start

Load a dataset, retrieve a vector sketch, and render it to a PNG:

from sketchkit.datasets import OpenSketch
from sketchkit.renderer import CairoRenderer

dataset = OpenSketch()
sketch = dataset[0]

renderer = CairoRenderer()
image = renderer.render(sketch)
image.save("rendering.png")

Save the example as quickstart.py, then run:

uv run python quickstart.py

The script creates rendering.png. On first use, the OpenSketch adapter downloads its dataset automatically. Datasets are cached under ~/.sketchkit/datasets by default; pass root=... to choose another location, or cislab_source=True to use the CIS LAB mirror where supported.

For complete pipelines covering vectorization, animation, NPR rendering, and stylization, see the Getting Started guide.

Unified Sketch Representation

Built-in dataset adapters convert sketches to the same vector structure:

Sketch
└── Path
    └── Curve
        ├── Start Point
        ├── Control Point 1
        ├── Control Point 2
        └── End Point

A Sketch contains paths, each Path represents a continuous stroke, and each Curve is a cubic Bézier segment. Points store coordinates and can also carry pressure, thickness, color, opacity, and custom attributes.

Learn more in the representation guide.

Supported Datasets

SketchKit currently includes 14 dataset adapters:

  • LineDrawer
  • QuickDraw
  • ControlSketch
  • TU-Berlin
  • Tracing vs. Freehand
  • OpenSketch
  • SketchX-PRIS
  • Sketchy
  • PhotoSketching
  • GMU Sketch Cleanup
  • FS-COCO
  • DifferSketching
  • CreativeSketch
  • SketchIME

Download behavior, source availability, metadata, and original representation vary by dataset. Check the dataset guide and its dataset-specific pages before starting a large download.

All dataset classes expose items_metadata, a pandas DataFrame for filtering by fields such as category, split, and identifier:

from sketchkit.datasets import ControlSketch

dataset = ControlSketch()
bears = dataset.items_metadata[
    (dataset.items_metadata["category"] == "bear")
    & (dataset.items_metadata["split"] == "validation")
]
sketches = [dataset[row.id] for _, row in bears.head(100).iterrows()]

See the dataset guide for storage, lazy loading, metadata, and dataset-specific documentation.

Methods

SketchKit organizes methods around sketches as the central representation. The table lists implementations documented in this repository; availability and setup requirements vary by implementation.

Task Documented implementations
Cleanup MasterSketch
Vectorization DeepVecSIG24, LineDrawer
Stroke ordering Fu, LineDrawer
Animation RIFE
Stylization NeuralBrushstroke
Image to sketch HED, PhotoSketch, SwiftSketch, AniLines
Sketch to image ControlNet, Pix2Pix, T2I-Adapter, Nano Banana 2
Colorization ControlNet Lineart, ControlNet Scribble, MangaNinja
3D modeling Teddy, SENS, Seed3D
Non-photorealistic rendering Suggestive Contours, Ridges and Valleys, Apparent Ridges

Some methods require pretrained weights, a CUDA-capable GPU, external services or credentials, or additional assets. Check the corresponding page in the methods guide before use.

Rendering

The rendering modules cover both 2D and 3D sketch visualization:

  • CairoRenderer rasterizes vector sketches with configurable canvas and stroke options.
  • CialloRenderer provides GPU-accelerated, brush-based vector stroke rendering.
  • DiffVGRenderer projects Sketch3D Bézier curves into one or more camera views.

See the 2D renderer guide and 3D renderer guide for examples and render options.

Documentation

The complete documentation is available at:

https://cislab.hkust-gz.edu.cn/projects/sketchkit/docs/

Useful entry points:

Contributing

Contributions for new datasets and processing methods are welcome. The manuals describe the expected unified interfaces, metadata conventions, module layout, tests, and GitHub workflow:

Metadata

Release files for sketchkit 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sketchkit 0.0.2
File Size Uploaded Provenance Actions
sketchkit-0.0.2.tar.gz 19.2 MB Without provenance Details for sketchkit-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sketchkit 0.0.2
File Interpreter ABI Platform Actions
sketchkit-0.0.2-cp312-cp312-macosx_12_0_arm64.whl CPython 3.12 CPython 3.12 macOS 12.0+ ARM64 Details for sketchkit-0.0.2-cp312-cp312-macosx_12_0_arm64.whl

Total release size: 21.7 MB

Release files / sketchkit-0.0.2.tar.gz

Download URL sketchkit-0.0.2.tar.gz
Size 19.2 MB
Tags Source
SHA-256 checksum
How to use checksums
26a96ceaf0486526ea2684897604c7958ed1685bf6b3f55f4653a0dc592d0919
BLAKE2b-256 checksum
How to use checksums
064b39ceee2d64746040cd0a5de4da3424d4675b7072379c62e9a36e5c004d43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.13

Release files / sketchkit-0.0.2-cp312-cp312-macosx_12_0_arm64.whl

Download URL sketchkit-0.0.2-cp312-cp312-macosx_12_0_arm64.whl
Size 2.5 MB
Tags CPython 3.12 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
b1371d546d50a10937d089f8c9b9d7f6284ae07515a83556b2ef70b41e3639d7
BLAKE2b-256 checksum
How to use checksums
1c2b7735eff2d98ed34ea11da6ab97b776e636d31a9a6b639cf83e74fa3b0657
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for sketchkit 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page