Sticker Lift
Tap the subject and it lifts off the photo as a sticker with a white die-cut edge. Slide to choose how much of it you take: a detail, a part or the whole thing.
Needs: A promptable segmenter that returns candidate masks as logits with a predicted IoU each. The preview runs SlimSAM (about 14 MB, downloaded in the browser) in a worker; the first look at a photo takes 20 to 30 seconds, every tap after that is instant.
Customize
photo
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | required | The photo. Same-origin or CORS-enabled: the sticker is cut from its pixels. |
| segment | (points: LiftPoint[]) => Promise<LiftMasks> | required | Runs the segmenter. Called with every point so far ({ x, y } as fractions, positive false for "not this"); resolve with { masks: Float32Array[] of logits, width, height, scores }. The newest call wins. |
| alt | string | "" | What the photo shows, read out with the controls. |
| dropTarget | RefObject<HTMLElement | null> | – | Where a sticker can be dropped, such as a chat. It gets data-mlui-over while a sticker hovers it; with onDrop, a Send button appears too. |
| onDrop | (sticker: Sticker) => void | – | Called with { blob, width, height, label } when the sticker is dropped on dropTarget or sent with the button. The blob is a transparent PNG with its border. |
| loading | string | null | – | While the model gets ready, what it is doing; shown over the photo. Taps still count and wait for it. |
| progress | number | null | – | How far along loading is, 0 to 1, when that is known. |
| border | number | 6 | Width of the white die-cut border, in CSS pixels. |
| offset | number | 1 | How far, in logits, the threshold moves to test whether an edge is stable. SAM uses 1; higher calls more edges soft. |
| className | string | "" | Extra class on the root. |
| style | CSSProperties | – | Inline style on the root. Set --mlui-radius for the photo's corners. |