Insights

Building AI Creator: from zero to a working app with local models

A single-day, three-commit build of a multi-tenant image-editing service — FastAPI, SQLite quotas, four ops, AnimeGANv2 + rembg, viewer, smoke — all running locally, no GPU.

All insights
11 min read
Dark engineering hero with the AI Creator title, five-up stats card (3 commits, 33 tests, 1.99 GB image, ~2 s per op, 0 GPUs), and the four-op provider chain diagram on the right

How a single-day, three-commit build turned a vague ask — 'AI edits on uploaded photos, no fine-tuning, no cloud lock-in' — into a shipping, multi-tenant, locally-runnable service with a viewer, four operations, and a passing test suite. The punchline is the local-models layer: an 8.2 MB AnimeGANv2 ONNX, a pre-baked u2net for backgrounds, and a vendor script that pulls LaMa when you turn it on.

Commits
3
Tests
33 / 1 / 0
Smoke
17 / 17
Image size
1.99 GB
GPU required
0

The brief: 'buy, don't build'

The ask came in plain terms: give the project creator some AI buttons. Customers upload photos; we want background removal, a stylized caricature, maybe inpaint. We are not going to train anything. Use whatever real models already exist — OpenArt, Replicate, fal.ai, Photoroom, remove.bg, Clipdrop.

Two constraints shaped the architecture from day one. Local-first: no AI op should fail just because a third-party API is down or quota-limited. Multi-tenant: the service sits behind the EFSS portal, and every request carries tenant, instance, and user IDs that get billed independently.

  • Every op has a chain: cloud provider → cloud fallback → local ONNX
  • Tenants and users each have their own token budgets; limits are configurable at runtime
  • Local fallback is the default; cloud is the optional premium path

Three commits, one calendar day

Commit one ships the package skeleton: a directory that builds as a standalone container, an HTTP boundary on a fixed port, an ops list the UI can render, and a SQLite schema that knows what a tenant is. Same conventions as the Trellis service that already shipped — same Makefile verbs, same CORS posture, same nginx snippet.

Commit two adds the multi-tenant quota engine and the local CPU caricature fallback so the service never 503s. Commit three replaces the OpenCV mesh-warp caricature with AnimeGANv2 face-paint v2, adds the local-model vendor pipeline, and wires in the LaMa ONNX import for inpaint (with an honest 'not ready' marker when opset mismatches).

The provider chain that never 503s

The provider abstraction in backend/providers.py is the heart of the design. Each op has a chain — caricature goes OpenArt MCP → Replicate InstantID → local AnimeGANv2; remove_bg goes Photoroom → Clipdrop → local rembg u2net; style and inpaint follow the same shape. The chain is consulted at request time, not at boot, so tenants can reconfigure their own chains without restarting the container.

The moment a link succeeds, the chain short-circuits. If every link fails, the user gets the chain's last error message — never a stack trace, never a generic 500. /health reports which link is live on each call.

  • AICREATOR_FORCE_LOCAL=1 keeps the service offline-capable for demos
  • Each backend is selected per-op via env vars; local paths override cloud
  • Missing local weights return clear 'run make vendor-aicreator' hints in /health

Local models: AnimeGANv2 face-paint v2

The caricature op shipped in commit two ran an OpenCV mesh-warp. The path existed, the test passed, but the output looked like a 1998 MS Paint filter — cartoonish in the bad sense. So we shipped a real neural model: AnimeGANv2 with the face_paint_512_v2 weights.

At 8.2 MB the ONNX file ships inside the image at /models/aicreator/animeganv2/. CPU inference takes about two seconds per 512×512 frame. Apache-2.0 weights + MIT code — no legal review needed. The same weights serve both the caricature and style ops.

The viewer: vanilla JS, no build

The viewer lives at /efss/aicreator/aicreator-viewer.html, served by the existing EFSS nginx so it inherits the same CORS origin. Drag a JPEG, pick an op, hit Run, see the result. Four tabs — remove_bg, caricature, style, inpaint — with a prompt textarea plus preset chips for the three creative ops.

A pleasant side effect of the no-build pipeline: the viewer is one self-contained HTML file with no node_modules. The same artifact deploys to staging, production, a developer's laptop, and a customer's self-hosted EFSS — no env vars, no script rewriting.

Tests, smoke, and what 'done' looks like

Five pytest files exercise the surface: 33 pass, 1 skipped, 0 fail, in 22 seconds. The smoke script drives curl against the live container and validates that every op returns a real PNG and that the viewer HTML is reachable through EFSS. 17 of 17 PASS, including the path that returns 503 for inpaint (the /health reason field carries the operator-facing message).

33 tests + 17 smoke checks is what 'done' means for AI Creator: not 'feature parity with Photoshop', but 'a deploy catches the regression before a customer report does'.

Run it on your laptop in three commands

git clone https://test.pryzmat.pl/root/jaisiu; cd jaisiu && make -C packages/aicreator build; make -C packages/aicreator run && make -C packages/aicreator smoke.

You now have a healthy container on :15555, the viewer at /efss/aicreator/aicreator-viewer.html, four ops wired, and 33 / 1 / 0 tests green. The full HTML write-up of the build — with sections the prose blog doesn't fit — sits in the work tree at /workspace/aicreator-summary-progress-details.html.

  • AI Creator
  • Local models
  • AnimeGANv2
  • rembg
  • FastAPI
  • Multi-tenant