Overview
The pitch is simple: gather a pile of old map scans, train a style LoRA on them, and see whether a diffusion model can learn to draw in the visual language of antique cartography -; the hand-lettering, the sepia, the decorative coastlines and sea monsters of a medieval mappa mundi. The unglamorous reality is that most of the work is in prep: scanner shadows, black borders, and inconsistent sizing all have to go before a single training step runs. The piece that actually exists today is that prep pipeline.
How It Works
Scans come in framed by dark borders and scanner shadow, which a style LoRA will happily
learn as "part of the map." A Python script (trim_black_borders.py) cleans
each one up, then standardizes it for AI-Toolkit. The trimmer iteratively peels rows and
columns from each edge whose mean brightness falls below a threshold, looping until the
bounding box stops moving -; trimming one edge shifts the perpendicular edges'
averages, so it has to converge. It measures the max channel per pixel rather
than overall luminance, so sepia paper still reads as "bright" and doesn't get eaten.
- Robust to gray/dim scanner-shadow borders, stray bright dust specks, and slight skew.
- Honors EXIF orientation; flattens alpha for JPEG output.
- Resizes the longest edge to a 1920px cap, aspect preserved, never upscaling, with LANCZOS resampling to keep fine map detail crisp. Trim happens before resize so you get 1920px of map, not map-plus-frame.
- Originals are never touched -; output goes to a sibling folder.
From there the cleaned dataset feeds AI-Toolkit for a Flux.1 style-only LoRA, with ComfyUI on the inference side for generation. The captioning leans minimal -; a bare trigger word -; on the theory that style is better learned from the pixels than described in text.
Current Status
This one is still in the prep-and-explore stage, and the page is honest about that. The cropping/resizing pipeline is complete and working -; tested end-to-end, shipped as a real script. The map LoRA training run itself isn't documented yet: there's a parallel oil-painting LoRA that exercises the same AI-Toolkit / Flux workflow, which is what the map version will follow once the dataset is assembled.
- Border-crop + resize pipeline: done and in use.
- Map dataset and the actual training run: still to come.
- Deskew was considered (via
cv2.minAreaRect) and deliberately skipped -; minor skew is fine, not worth the complexity.