/ Модель

Характеристики

Лицензия
Своя лицензия
Опубликована
23 июн 2026

shapes

Классификация изображенийИзображение → label3 профессии

Компактная модель для распознавания нарисованных от руки фигур и отметок с преобразованием их в аккуратные контуры в приложениях для рисования.

2 941скачиваний за 30 дней8лайковвеса обновлены25 ноя 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Shapes — компактная модель распознавания нарисованных от руки фигур, предназначенная для использования в SDK на устройствах. Она принимает траектории пера, касания или мыши и классифицирует один рисунок как одну из геометрических фигур или отметок, после чего возвращает координаты и параметры для построения аккуратного контура. Поддерживаются круги, эллипсы, прямоугольники, многоугольники, звёзды, сердца, облака, линии, стрелки и соединители, а также галочка, крест, плюс, скобка, зигзаг и каракули.

В README указано, что модель распознаёт рисунок примерно за 0,92 мс на iPhone 16 Pro. Доступны сборки Core ML с 4-битными палетизированными весами размером 860 КБ и LiteRT/TFLite с 8-битными весами размером 1,8 МБ; заявлены платформы Apple, Android, Linux, Windows, браузер и Node. SDK позволяет настраивать допуск поворота и порог уверенности, а также предварительно показывать результат во время рисования.

Модель рассчитана на распознавание одного объекта за вызов: приложение само группирует штрихи. Пятиугольники могут распознаваться как шестиугольники, рыхлые каракули могут не распознаваться, а незаконченные прямоугольники иногда классифицируются как открытые отметки. Лицензия указана как other; конкретные условия в предоставленных данных не раскрыты.

Сценарии применения

  • выравнивание нарисованных от руки кругов и прямоугольников
  • распознавание стрелок и соединителей на холсте
  • преобразование набросков фигур в чистые контуры
  • распознавание галочек и крестиков в интерфейсе
  • распознавание жеста стирания по каракулям

Ограничения

За один вызов распознаётся только одна фигура, поэтому приложение должно самостоятельно объединять штрихи в рисунки. Пятиугольники иногда классифицируются как шестиугольники, рыхлые каракули могут не распознаваться, а незавершённые прямоугольники иногда принимаются за другие отметки.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Shapes

Snap hand-drawn shapes to clean ones.

On-device shape recognition for pen, touch and mouse input.

PlatformsiOS, macOS, tvOS, visionOS, Android, Linux, Windows, Browser, Node
Weightsv2.2.0
Demohttps://desertant.com/models/shapes/

Draw a rough circle and Shapes snaps it to a clean one. Boxes, diamonds, stars, hearts, clouds, arrows and connectors snap the same way, drawn in one stroke or several. Shapes works with a pen, a finger, a mouse or a trackpad. It recognizes a stroke in 0.92ms on an iPhone 16 Pro.

Shapes also recognizes six marks: a check, a cross, a plus, a bracket, a zigzag and a scribble. The app decides what each mark does: a check can tick off an item, and a cross can reject a step. Shapes returns each shape in canvas coordinates, as the points and sizes to draw it, such as the four corners of a box.

Install

Swift (requirements)

.package(url: "https://github.com/Desert-Ant-Labs/desert-ant-core.git", from: "6.0.0")

Then add the Shapes product to your target.

Kotlin (requirements)

implementation(platform("ai.desertant:bom:6.0.0"))
implementation("ai.desertant:shapes")

JavaScript (requirements)

npm i @desert-ant-labs/shapes @litertjs/core   # browser
npm i @desert-ant-labs/shapes                  # Node, prebuilt native core

Usage

Swift

import Shapes

let shapes = Shapes()
let shape = try await shapes.recognize(strokes: [
    Stroke(points: across),                        // the strokes since the user paused, in drawing order
    Stroke(points: down),
])
switch shape {
case let .rectangle(corners)?: ...                 // [Point], around the perimeter
case let .arrow(from, _, _, to, startHead, endHead)?: ...
case let .plus(firstFrom, firstTo, secondFrom, secondTo)?: ...
case let .scribble(hull)?: ...                     // delete what the hull covers
case let shape?: draw(shape.paths())               // polylines for any shape
case nil: ...                                      // not a shape: keep the ink
}

Pass the strokes of one drawing: the app decides which strokes belong together, usually the strokes since the user last paused. For a single stroke, recognize(points:) takes its points. A Stroke can also carry the time of each point in milliseconds; give times for every stroke or for none.

Each call takes Options:

  • rotation: .snapped is the default. Shapes rounds a shape's rotation to 15° steps and snaps lines and edges within 5° of horizontal or vertical onto the axis. .upright removes rotation: boxes and ellipses align with the axes, a plus sits on the axes and a cross at 45°. .free keeps the shape as drawn.
  • kinds: the kinds Shapes recognizes. Leave out .scribble if the app has no erase gesture, or .arrow if the app adds arrowheads to lines itself.
  • minimumConfidence: the lowest model confidence Shapes accepts, on top of its own checks.
  • isFinished: true by default, for the moment the pen lifts. A finished outline snaps only once the whole outline is drawn, so a box missing a side comes back nil. Pass false for a preview while the pen still moves.

Unless rotation is .free, Shapes also snaps a near-square box to a square, a near-circular ellipse to a circle and a near-regular polygon to a regular one. The two strokes of a plus or a cross meet square, with equal arms when they're close in length; a bracket's spine is straight and its ends square; a check's corner is square.

Shape.paths(samples:) returns polylines for any shape, one per stroke for a plus or a cross, and Shape.arrowheads(length:) returns an arrow's heads. On Apple platforms, Shape.path returns a CGPath.

On iOS and visionOS, enableShapeSnapping() turns on live snapping in a PencilKit canvas. When the user pauses mid-stroke, the canvas previews the recognized shape. When the user lifts the pen, the SDK replaces the stroke with the clean shape, and a scribble erases the strokes inside its hull. Strokes drawn with no pause longer than strokeGap, 1s by default, are read together, so a plus drawn in two strokes snaps as a plus. The SDK registers each change with the canvas's undo manager, so undo and redo work.

canvasView.enableShapeSnapping()

Kotlin

import ai.desertant.shapes.Options
import ai.desertant.shapes.Rotation
import ai.desertant.shapes.Shape
import ai.desertant.shapes.Shapes
import ai.desertant.shapes.Stroke

Shapes(context).use { shapes ->
    val shape = shapes.recognize(listOf(Stroke(across), Stroke(down)), Options(rotation = Rotation.UPRIGHT))
    when (shape) {
        is Shape.Scribble -> eraseUnder(shape.hull)
        is Shape.Arrow -> draw(shape.outline, shape.arrowheads(length = 12.0))
        null -> keepInk()
        else -> draw(shape.paths)
    }
}

JavaScript

import { Shapes, arrowheads } from "@desert-ant-labs/shapes";       // browser
// import { Shapes } from "@desert-ant-labs/shapes/native";           // server-side Node

const shapes = await Shapes.load();
const shape = await shapes.recognize([{ points: across }, { points: down }], { rotation: "upright" });
if (shape?.kind === "scribble") eraseUnder(shape.hull);
else if (shape?.kind === "arrow") draw(shape.outline, arrowheads(shape, 12));
else if (shape) draw(shape.paths);                                    // null: keep the ink
shapes.dispose();

recognize also takes one stroke as [{x, y}, ...] or [x0, y0, x1, y1, ...]. In Kotlin and JavaScript, paths gives a plus or a cross as its two strokes, as paths() does in Swift.

What comes back

The kinds and their fields are the same in Swift, Kotlin and TypeScript. Every shape also has an outline.

KindFields
linefrom, to: a straight connector
curvefrom, control1, control2, to: a curved connector, a cubic Bezier
arrowfrom, control1, control2, to, startHead, endHead: a connector with a head at one or both ends
rectanglecorners: four points around the perimeter; a square is a rectangle
ellipsecenter, semiMajor, semiMinor, rotation; a circle is an ellipse
triangle, diamond, pentagon, hexagonvertices, around the perimeter
starcenter, outerRadius, innerRadius, rotation, pointCount
heartcenter, width, height, point down
cloudthe outline of its bumps
checkstart, corner, end: the short arm's end, the corner, the long arm's end
cross, plusfirstFrom, firstTo, secondFrom, secondTo: its two strokes
bracketpoints: from its top end, through its two corners, to its other end
zigzagfrom, to, amplitude, teeth: 2 * teeth straight runs
scribblehull: the convex hull of the scribble, for an erase gesture

For a drawing that isn't one of these kinds, or an outline that isn't finished, Shapes returns nil (null in Kotlin and JavaScript).

Loading the model

Every SDK downloads the weights from Hugging Face on first use and caches them. See model downloads and caching.

Files

FileFormatSizeContents
coreml-palette4/shapes.mlmodelcCompiled Core ML, 4-bit palettized weights860KBThe model on Apple platforms (Swift SDK)
litert-int8/shapes.tfliteLiteRT, 8-bit weights1.8MBThe same model on Android, Linux, Windows, Node and the web (Kotlin, JavaScript, and Swift off Apple platforms)
coreml-palette4/shapes_meta.json, litert-int8/shapes_meta.jsonJSON9KBThe kinds in output order, how the SDK prepares a drawing, where each kind's numbers sit in the outputs, and the limits of the checks after the model

Inputs and outputs

The SDK prepares a drawing of up to 32 strokes as 256 points spread along its ink, with five numbers per point: x, y, the step to the next point in x and in y, and whether a stroke starts there. Both builds take x [1, 256, 5] and stroke [1, 256] (each point's stroke) and return kind_logits [1, 18], a score for each of the 17 kinds and for not a shape, and numbers [1, 125], the numbers of every kind's template. The SDK takes the most likely kind, fits its template to the ink from those numbers, checks that the fit lies on the ink and that a closed outline is drawn, and snaps the shape per Options.

Results

On flowcharts people drew by hand, Shapes recognizes the right kind for 98.4% of boxes, ovals, diamonds and arrows. On quick doodles from a drawing game, Shapes gets 85.7% right, and the gemstones in the diamond class pull that figure down.

We tested Shapes on two public sets of drawings that the model never trained on, through the Swift SDK on the Core ML files. Each figure is the share of drawings where the model's most likely kind is the kind drawn, before the SDK checks the fit.

SetKindDrawingsAccuracy
Quick, Draw!all nine11,75085.7%
circle1,32191.4%
cloud1,22194.2%
diamond1,31333.9%
hexagon1,43288.5%
line1,41888.1%
square1,26992.0%
star1,36496.3%
triangle1,22595.7%
zigzag1,18792.3%
DIDIall four28,10298.4%
arrow14,63298.2%
box4,58398.4%
diamond4,50598.3%
oval4,38299.0%

Quick, Draw! is Google's set of doodles people drew in under 20 seconds in a browser game. We used every test drawing in the nine classes that match a Shapes kind. Most drawings in its diamond class are faceted gemstones, which Shapes treats as not a shape.

DIDI is Google's set of flowcharts people drew by hand, copying a diagram shown on screen. We cut every clean box, oval, diamond and arrow out of its 7,330 test drawings, matching each drawing to the diagram it copied.

On Android, Linux, Windows and the web, the LiteRT file scores within 0.6 points of the Core ML file on both sets.

No public set of drawings holds checks, crosses, pluses, brackets, scribbles, pentagons or hearts, so the table leaves those kinds out.

Performance

Shapes recognizes a stroke in 0.56ms on a MacBook Pro M5 Pro and in 1.4ms on Linux. Each time is the median of 100 calls through the SDK, after a warm-up, for one stroke of up to 96 points. The times leave out loading the model.

DeviceRuntimePer stroke
MacBook Pro, M5 ProCore ML0.56ms
iPhone 16 ProCore ML0.92ms
Linux, x86-64LiteRT, CPU1.4ms
MacBook Pro 16, M1 MaxCore ML2.8ms
Mac mini, M1Core ML3.0ms
Windows, AMD Ryzen AI 300LiteRT, CPU3.4ms
Windows, Intel Core Ultra 200VLiteRT, CPU7.8ms

Limitations

  • Shapes recognizes one shape per call, and the app decides which strokes belong to it. Two shapes passed in one call come back as not a shape or as one of the two.
  • Shapes often reads a hand-drawn pentagon as a hexagon. Of 20 pentagons one person drew on a trackpad, Shapes read 17 as hexagons.
  • A loose scribble of loops often comes back as not a shape. Of 20 such scribbles from the same person, Shapes read none as scribbles.
  • A diamond drawn as a faceted gemstone comes back as not a shape or a triangle.
  • A box drawn only halfway sometimes comes back as an open mark, such as a check, a bracket or a zigzag: up to 19 of 300 boxes on Apple platforms and 28 of 300 on Android, Linux, Windows and the web. Once 70% of the box is drawn, at most 1 of 300 does.

License

Desert Ant Labs Source-Available License. Free for most apps, and a commercial license is required at scale. Full terms are at the link. Licensing: licensing@desertant.com.

Third-party notices for the weights: THIRD_PARTY_NOTICES.md.

Citation

@software{shapes_2026,
  title  = {Shapes: On-device shape recognition for pen, touch and mouse input},
  author = {Desert Ant Labs},
  year   = {2026},
  url    = {https://huggingface.co/desert-ant-labs/shapes},
}

© 2026 Desert Ant Labs · https://desertant.com

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

В репозитории нет config.json: не понять архитектуру модели.

Ревизия весов
a78a4ff

0 моделей