Text Fix: fix the gibberish text on generated images
In active development. Version 0.9 brings everything that was planned: an optional neural text detector that also finds large, heavy and hand-written lettering and reads the old text, outlines, shadows, two colors and materials, text along a path or over folds, variants of the model pass with ControlNet guidance, presets, an auto mode during generation and whole folders at once. Feedback and bug reports are very welcome.
Image models write POLLICE on a police vest and LTAANING over a bakery. Text Fix finds that text, wipes it and writes yours in its place: same spot, size, slant, bend and color, lit the way the surface under it is lit. The model then blends the letters in with a light inpainting pass. No image editor needed.
One download, two hosts: an extension for AUTOMATIC1111, Forge and reForge, and a custom node for ComfyUI.
Features
Finds the text: every line that looks like text is outlined when an image arrives, and a click finds what the search missed
Erases it: the old letters are painted over with the surface they were written on
Writes yours in the same place, at the same size, slant and bend, with strokes as thick as the old ones, in the old color, with the light and shadow of the surface
A visual editor of its own: it opens over the WebUI page or from the ComfyUI node, and the new text shows at once and follows every setting, with no model involved
Blends it in: one light inpainting pass over that spot, so the letters take on the texture of the surface
Several lines at once: pick any number of texts and give each its own line
Shape the selection by hand: drag its corners, bend it, move it
Blocks of lines: join the lines of a bubble or a sign into one block and type its text with line breaks; split it again
Eraser brush and Erase only: paint over leftovers the search missed, or wipe text without writing anything new
A neural text detector (optional, one button): finds large, heavy, faint and hand-written lettering that the search by looks misses, and puts what the old letters say into the text field as a start
A look of its own: outline, shadow, two colors or a gradient, and materials (embroidery, worn stencil, neon, engraving); Match finds the fonts most like the old letters
Any shape: text along a path you draw, bent by a warp grid, or following the folds of the cloth
A better model pass: up to 4 variants to pick from, before and after under a divider, prompts cleaned of words that ask for text, and ControlNet guidance by the letters' edges
Without opening the editor: an auto mode that writes a list of new texts onto every generated image, a whole folder at once, presets for the look, Send to img2img and inpaint, and a Text Fix Blend node for ComfyUI
30 fonts: 16 bundled, a few system ones, and any you drop into the fonts folder
How to use
Generate an image and press the icon with the letter A in the row of tools under Generate. The editor opens over the page with the image.
The text found on the image is outlined in yellow. Click the one to replace. A click anywhere else looks for text at that spot.
Type the new text. The result shows it at once and follows every setting as you change it.
Press Blend in with the model, then To gallery or Save.
For several texts at once, switch the click to Add a line, click each text in turn and type one line of text for each number. Press Join to take them as one block: a line break in its text starts a new line.
ComfyUI
Add the Text Fix node (category image/postprocessing) after VAE Decode. It gives three outputs: the image with the text replaced, a mask of the places it wrote on (feed both to an inpainting pass at a denoise of 0.25 to 0.35 to blend the letters in), and a preview with everything it found numbered. The Text Fix Blend node does that inpainting pass in one step: give it the image, the mask, and the model, conditioning and VAE of the workflow. Run the workflow once, then press Open editor on the node: the same editor opens, and what you pick and type there is kept in the node for the next run.
Requirements
AUTOMATIC1111, Forge or reForge, or ComfyUI
Nothing extra to install: numpy, opencv, Pillow and onnxruntime already ship with both hosts
No models needed: the blending pass uses the checkpoint you have loaded. The optional detector and reader (PaddleOCR PP-OCR in ONNX, Apache-2.0) are fetched by a button in the editor: 12.6 MB, or 88 MB more for the full detector
Installation
WebUI (A1111, Forge, reForge): open Extensions, then Install from URL, paste https://github.com/KazeKaze93/sd-text-fix and click Install. Restart the UI.
ComfyUI: clone https://github.com/KazeKaze93/sd-text-fix into ComfyUI/custom_nodes and restart ComfyUI.
To update either one, run git pull in the sd-text-fix folder, restart the host and refresh the browser page.
Limits
Without the detector the search goes by looks alone: large, faint or hand-written text is missed, and now and then a lock of hair or an eye is taken for text. Get the detector (one button), and keep the originals in the auto mode (it does by default).
The reader reads Latin letters only for now.
Bent text is followed as far as a smooth curve goes (a mug, a sleeve, a banner), not across sharp folds.
At a higher denoising strength the blending pass can change a letter, most of all on a fold or a seam. Pick another variant, lower the strength, or guide the pass with ControlNet.
Tested mostly on reForge so far.
What is next
Next: reading other scripts (Cyrillic, Japanese and the rest), a click that uses the detector too, and relief from a depth estimate. The full roadmap is on GitHub.
More
Full documentation, the roadmap and the source: github.com/KazeKaze93/sd-text-fix. Found a bug or want a feature? Open an issue on GitHub or leave a comment here.
The code is AGPL-3.0. Images you fix with this tool are yours.
Description
Everything that was planned, in four steps since v0.5. Still in active development.
Finding and reading: an optional neural text detector (PaddleOCR PP-OCR in ONNX, fetched by a button: 12.6 MB light, 88 MB full). It finds large, heavy and hand-written lettering the search by looks misses, is not fooled by hair or eyes as often, and puts what the old letters say into the text field as a start.
The look: outline, shadow, two colors or a gradient, materials (embroidery, worn stencil, neon, engraving), Match for the fonts most like the old letters, text along a drawn path, a warp grid, and Follow the folds.
The model pass: up to 4 variants with their own seeds, Compare (before and after under a divider), words that ask for text left out of the prompt, and ControlNet guidance by the letters' edges when the host has a canny or lineart model.
Workflow: presets for the look, img2img and Inpaint buttons in the editor, an auto mode during generation with a list of replacements (it keeps the image as generated too), a whole folder at once, and a Text Fix Blend node for ComfyUI.


