← back to SERVICE

AMI OC-Generator

A tool that helps artists draw the company's original characters (OCs). It makes a first pass from a character and a pose, then upscales it and separates line art and color into a layered PSD. A product of the AMI project.

stack
TypeScript, Next.js, React, Tailwind CSS, PostgreSQL, NextAuth, sharp, Gemini API, OpenAI Image API, NovelAI API, Photopea, Vitest, Docker, GitHub Actions
Drawing time

-25%

4 days → 3 days for 6 cuts

AI generation success

95.1%

693 runs during development

What I did
  • Built the OC-Generator pipeline, which supports drawing instead of replacing it.
  • Kept improving it based on feedback from the people who used it.

Problem

Drawing original characters took a lot of time. Generating them with AI was not an option, because readers on the platforms strongly reject AI content.

What I built

It helps artists draw instead of generating characters. A character image, a pose image and a prompt produce first passes. The artist picks one and adjusts appearance such as body shape by hand, then AI cleans the white background, upscales to 4K, extracts the line art and flattens the color. The result is a layered PSD that the artist retouches and finishes.

It is an eight-step pipeline that alternates AI steps and human steps, and a person picks the result at every step. A gallery allows free-form work outside that order, and a marked area can be fixed alone with NovelAI inpainting.

Trial and error

  • A CLI that never answered: The codex CLI used for image generation waited on input and never printed its output path, so every generation failed. Input is now closed right away, and on Windows, where a security patch (CVE-2024-27980) blocks running .cmd files, it runs through node directly.
  • Mixed-up results: A fallback that picked “the newest PNG” sometimes grabbed another run’s image. The app now trusts only the path its own run printed.
  • A default model that changed: When the CLI’s default model changed, step 1 failed everywhere. Images are recovered from the session folder, and the model is pinned in settings.
  • Matching models to steps: At first one model ran every step. Each step now uses the model that suits it, and line and color extraction got a fallback path.
  • Erasing objects with NovelAI: It left semi-transparent patches or drew the object again. Seven attempts showed three things were needed: overwrite the original pixels inside the mask, leave the object’s name out of the prompt (even a negation drew it), and widen the area by 30px.
  • Dev and production on one build: A build wiped the running dev server’s output, which cut logins for 1–2 minutes. Builds now use separate slots, and the server is swapped only when no job is running.

Quality and operations

  • Tests: About 160 tests (Vitest with an in-memory database) check the pipeline and the API.
  • Stability: Concurrency is capped at 4 for Gemini and 2 for codex, and only quota errors fail over to another account. There is no automatic retry, to avoid double charges.
  • Security: Every API route checks the login, image imports are guarded against SSRF, and only allow-listed Google accounts can sign in.
  • Deployment: A GitHub Actions self-hosted runner deploys to an in-house server.
  • Generation log: During development, 693 AI generations ran with a 95.1% success rate, and every call records its tokens and an estimated cost.

Results

  • Drawing time dropped by 25%, from 4 days to 3 days for 6 cuts.