How it works
Saimiri simulates what a designer does by hand: draw circles and lines over the photo, then choose which regions they form.
The idea
The designer does not draw the final outline. They draw a small set of primitives, and the outline emerges from the arrangement of those primitives plus the choice of which regions to keep. That is cheap to compute, so only the segmentation of the subject needs a neural network.
The stages
- Segment. A 4.6 MB network (U²-Netp) cuts the subject out once per image: 0.16 s on the GPU (RTX 3050, Vulkan) and 0.83 s on the CPU, which is the automatic fallback.
- Contour. The outline of the largest region, smoothed and shifted half a pixel outward so that fitted shapes match the mask's area.
- Lines and arcs. Dynamic programming picks the fewest lines and circular arcs within an error bound; one number (λ) trades detail for simplicity.
- Construction grid. Arcs become full circles, lines get overshoot, inscribed circles and a base line are added, near-duplicates merged.
- Snap. Parallel lines, equal radii, tangencies, round angles and common bases are aligned, but only while the shape stays faithful.
- Faces. The grid cuts the image into faces, exactly (a planar subdivision of lines and arcs). A min-cut keeps the faces that mostly lie inside the subject and drops slivers.
- Path. The kept faces become one outline made only of line segments and arcs: a clean SVG with few nodes, plus the grid that produced it.
Speed and memory
Only the segmentation touches a neural network. The first run on the GPU also compiles shaders (0.52 s for that first image) and peaks at 411 MB of memory; the CPU path peaks at 274 MB. Every later stage is classical geometry that runs in milliseconds, and each stage caches its result, so moving a slider only recomputes what depends on it.
Measured on one machine; numbers and method are in the repository's measurements.