<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: yang li</title>
    <description>The latest articles on DEV Community by yang li (@sun4lower).</description>
    <link>https://dev.to/sun4lower</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4049684%2F3eda63e1-2645-475f-965e-c54f3e88fb20.png</url>
      <title>DEV Community: yang li</title>
      <link>https://dev.to/sun4lower</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sun4lower"/>
    <language>en</language>
    <item>
      <title>Making an AI cat sticker maker that keeps the same cat across poses</title>
      <dc:creator>yang li</dc:creator>
      <pubDate>Mon, 27 Jul 2026 14:27:45 +0000</pubDate>
      <link>https://dev.to/sun4lower/making-an-ai-cat-sticker-maker-that-keeps-the-same-cat-across-poses-o2h</link>
      <guid>https://dev.to/sun4lower/making-an-ai-cat-sticker-maker-that-keeps-the-same-cat-across-poses-o2h</guid>
      <description>&lt;p&gt;Making an AI cat sticker maker that keeps the same cat across poses&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://stickfur.com" rel="noopener noreferrer"&gt;an AI cat sticker maker&lt;/a&gt; — you upload one photo of your cat and it returns six stickers in different poses (happy, crying, sleepy, shocked…) that still look like &lt;em&gt;your&lt;/em&gt; cat. Here are the three problems that actually took work, and how I solved them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Identity consistency across poses
&lt;/h2&gt;

&lt;p&gt;The naive approach — prompt the model six times with "a cute cat sticker, happy / sad / …" — gives you six &lt;em&gt;different&lt;/em&gt; cats. The fix was a two-stage pyramid:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate one &lt;strong&gt;canonical reference&lt;/strong&gt; from the uploaded photo, with an explicit identity checklist in the prompt (fur color, markings, face structure, eye/ear/nose shape, proportions).&lt;/li&gt;
&lt;li&gt;Condition every pose on that canonical, repeating the "must be the SAME individual cat" constraint.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Randomizing &lt;em&gt;which&lt;/em&gt; six poses to draw is done in backend code (Fisher–Yates over a pose pool), not left to the model — that keeps the workflow deterministic on retries.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Background removal on white cats
&lt;/h2&gt;

&lt;p&gt;Stickers need a transparent cut-out. I first wrote a classic chroma-key pipeline (flood-fill from the edges, despill, etc.). It works — until you get a &lt;strong&gt;white cat on a white background&lt;/strong&gt;, where the fur, the whiskers and the background are all nearly the same color. That's an ill-posed problem for color-based keying.&lt;/p&gt;

&lt;p&gt;Switching to a neural matting model (&lt;strong&gt;BiRefNet&lt;/strong&gt;) was the single biggest quality jump: it segments the subject semantically, so white fur, fuzzy edges and thin whiskers all come out clean. The old algorithm stays as a fallback if the matting call fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. A die-cut border that ignores whiskers
&lt;/h2&gt;

&lt;p&gt;Printable stickers want a clean, &lt;strong&gt;constant-width&lt;/strong&gt; white border. A naive dilation of the silhouette gives a border whose width varies with local curvature — it looks amateurish. And thin whiskers make the cut line spiky and impossible to actually cut.&lt;/p&gt;

&lt;p&gt;The fix: compute a &lt;strong&gt;Euclidean distance transform&lt;/strong&gt; of the silhouette and threshold it, so the border is mathematically the same width everywhere. Before that, a small blur+threshold smooths thin whiskers out of the &lt;em&gt;cut&lt;/em&gt; outline (they stay inside the sticker, they just don't dictate where you cut).&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack notes
&lt;/h2&gt;

&lt;p&gt;The whole thing runs on &lt;strong&gt;Cloudflare Workers&lt;/strong&gt; (Next.js via the OpenNext adapter), with the image pipeline in a Workflow. The tight per-step CPU budget on Workers was a real constraint — I ended up hand-rolling a fast PNG encoder and doing all the matting math on typed arrays.&lt;/p&gt;




&lt;p&gt;If you want to see the output, you can try the &lt;a href="https://stickfur.com/custom-cat-stickers" rel="noopener noreferrer"&gt;custom cat stickers&lt;/a&gt; generator — it's free to generate and preview. I'd love feedback on the sticker quality, especially edge cases (long-haired cats, unusual markings).&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
