Sketchy¶
Sketchy is a SketchDataset loader for the SVG subset of The Sketchy Database. The dataset contains vector-based sketches categorized by class name. It natively handles pruning invalid or ambiguous sketches based on the dataset’s provided annotation text files.
Source: datasets/sketchy.py
Data Format¶
Each sample is an SVG file containing vector paths. The loader parses the XML tree and handles:
<path>elements: Thedattribute is parsed to extract control points. Supported commands includeMoveandCubicBezier.Linesegments are automatically converted into cubic Bézier representations.Dimensions: Canvas dimensions are extracted from the SVG
viewBoxor fallbackwidth/heightattributes.Unsupported elements: Primitive SVG shapes (like
rect,circle,ellipse,line,polyline,polygon) and path transforms are ignored or unsupported by this parser.
Each path is converted into a Path composed of cubic Bézier Curves to remain consistent with SketchKit’s unified format.
Directory Layout¶
After download and extraction, the dataset is expected under:
<root>/
sketches/
airplane/
n02691156_58-1.svg
...
invalid.txt
apple/
...
sketches-06-04.7z
.metadata.parquet
<root>/sketches/contains subfolders for each class name.Each class folder contains its respective
.svgfiles and aninvalid.txtfile listing unidentifiable or erroneous sketches (which are tracked via theprunedmetadata column).
Code¶
from sketchkit.datasets import Sketchy
ds = Sketchy(cislab_source=True)
sketch = ds[0]
print(sketch.width, sketch.height)
print(sketch.path_num, sketch.curve_num)
# Filter out pruned (invalid) sketches for a specific class
valid_airplanes = ds.items_metadata[
(ds.items_metadata["class_name"] == "airplane")
& (ds.items_metadata["pruned"] == False)
]
sketches = [ds[row.id] for _, row in valid_airplanes[:5].iterrows()]
Arguments
cislab_source: Selects the download source. IfTrue, the dataset is downloaded from the CISLAB CDN mirror; otherwise it is downloaded from official host.CISLAB mirror:
https://cislab.hkust-gz.edu.cn/projects/sketchkit/datasets/Sketchy/sketches-06-04.7zOfficial host:
https://drive.google.com/file/d/1Qr8HhjRuGqgDONHigGszyHG_awCstivo
Metadata Columns
id: Global unique identifier across all sketches.pruned: Boolean flag indicating if the sketch was listed in the category’sinvalid.txtfile.category: The class category of the sketch (e.g., “airplane”).filename: The specific SVG file name (e.g., “n02691156_58-1.svg”).path: The absolute path to the SVG file.sketch_name: The relative identifier combining class and filename (e.g., “airplane/n02691156_58-1.svg”).split: Split in the dataset (e.g., “train”, “valid”, or “test”).