Turning an AI-generated concept image into something a printer can actually use — at every stage, the fast model was wrong and the boring model was right.
Built for TeamTime, a custom-apparel manufacturing client, as part of the "AI designs it, we make it real" pipeline.
Apparel manufacturing
An AI image model can generate a striking apparel concept in seconds. What it can't do is hand a print shop a usable file. Between "cool image" and "manufacturable artwork" sit two separate hard problems: pulling the actual design element cleanly out of the generated image, and getting it to a resolution that survives being printed on fabric.
Two separate builds, two separate failures, two separate fixes.
The instinct was to own this rather than depend on a hosted API. A production FastAPI service was built around Meta's Segment Anything Model (SAM): multiple variants (vit_h, vit_l, vit_b), automatic and box-prompted segmentation, RGBA extraction with background transparency, async batch processing through Celery, Postgres and Redis underneath, fully containerised and monitored.
It worked exactly as advertised, and that turned out to be the problem.
Give it an image and it hands back accurate pixel masks — a shirt, a logo, a background. What it has no concept of is layout: how those masks relate, where a design element sits on a garment, how to reconstruct a clean composition from a pile of correct-but-disconnected masks. Getting from "here are your segments" to "here is your artwork" meant manually assembling the masks by hand, every time.
A tool that requires a human to finish its output isn't automating the step — it's just changing what the human does.
The fix wasn't a better segmentation model. It was recognising that segmentation was the wrong layer of the problem. Nano Banana — a hosted image model with actual compositional understanding — replaced the custom pipeline outright. Worse per-call economics, far better output: it returned something closer to finished artwork rather than raw material a human still had to lay out.
A technically correct component can still be solving the wrong sub-problem. SAM's masks were accurate. They just weren't the thing that was actually needed.
A usable design still has to survive being upscaled to print size without falling apart — and this is where text and logos, the exact elements a client cares most about, are least forgiving of a bad model.
The starting point was the obvious one: call a hosted Real-ESRGAN endpoint on Replicate. It worked. It was also expensive per call, and cost scales badly against a pipeline meant to run per-order rather than per-project.
The direct fix for cost was to stop paying per call — run the same class of model locally instead, GPU-aware with CPU fallback, async job processing with webhook callbacks. Cost problem solved. New problem: Real-ESRGAN distorted text and logos. It doesn't understand that a straight edge on a letterform has to stay straight, or that a logo's proportions are load-bearing information. On apparel artwork — mostly typography and brand marks — it's the one failure mode that actually matters to the client.
The fix was switching to HAT (Hybrid Attention Transformer). GANs like Real-ESRGAN hallucinate plausible texture; a transformer architecture handles structural detail — edges, straight lines, character shapes — with more fidelity, which is precisely the property text and logos need.
The API was built to support both models behind one interface (model_type: esrgan or hat), so the choice is a parameter rather than a rewrite, and it can be verified per job rather than assumed.
Every stage of this pipeline followed the same shape: try the capable general-purpose tool, discover the specific way it fails on this exact content, and swap in whichever model actually respects the constraint that matters — layout for extraction, structural fidelity for upscaling. SAM and Real-ESRGAN are both excellent, well-regarded models. They were also both wrong for this specific job, and the only way to find that out was building the pipeline, running it against real apparel artwork, and watching exactly where it broke.
An AI-generated apparel concept needs two things before it can become a physical product: a clean extraction of the actual design element, and a print-resolution version that doesn't warp the text and branding a customer is paying for. This project is the record of finding, the hard way, which models actually deliver both.