Fine-tuning my first AI Model to make an Anime Map of Mauritius

How a side experiment on Moris 3D turned into my first FLUX.2 LoRA, 1,320 map tiles covering Mauritius for around $17 in GPU credits, and my first releases on Hugging Face.

  • Written by Sandeep Ramgolam
Written by

Sandeep Ramgolam

Fine-tuning my first AI Model to make an Anime Map of Mauritius

Fine-tuning my first AI Model to make an Anime Map of Mauritius

For the past few weeks I've been building Moris 3D, a fun 3D elevation map of Mauritius with real building footprints, roads, live flights, ships, and the Metro Express. While working on it I saw Isometric NYC and Isometric SF on twitter, which render big isometric illustrated city maps on top of real 3D geometry in a city builder game style. I've also been binge watching Naruto & Shippuden for the past two months and was absolutely in love with the look and feel of the Leaf Village in the anime. Naturally i was curious to see what Mauritius would look like in a bright, hand-inked anime map style, with every street, roof, coastline, and mountain ridge aligned 1:1 to real data so you can zoom into your own neighbourhood and recognise it.

That ended up leading me to train my first LoRA, generate 1,320 tiles covering Mauritius (1,877 km²) for about $17 in GPU credits, debug a bunch of weird image-generation bugs, and publish the model, dataset, and demo Space on Hugging Face.

You can browse the map at moris3d.ramgolam.com/anime, or drag the slider below to compare the raw 3D renders against the LoRA output across five spots on the island:

Port Louis: 3D semantic whitebox renderPort Louis: hand-inked anime LoRA output3D WhiteboxAnime LoRA
Port Louis: Capital CBD, Place d'Armes, Caudan Waterfront, and harbour piers locked 1:1 to real building footprints. Drag slider or use ← / → keys

Starting with Port Louis

Because I already had Moris 3D running, I didn't need Google 3D Tiles or new geometry data. I already had:

  • 1m LIDAR and 30m elevation data for the island
  • 435,081 real building footprints with heights
  • Full road networks and Port Louis harbour geometry
  • A headless Chrome + Three.js capture script

I locked an orthographic isometric camera over Port Louis harbour looking southeast (142° azimuth, 32° tilt). That puts Caudan Waterfront and the harbour in front, downtown Port Louis in the middle, and Signal Mountain, Le Pouce, and Pieter Both directly behind the city. Dope view right?

Generating tiles with Nano Banana (and hitting usage limits)

To keep every building and road in the exact same place, I rendered flat color-coded "whitebox" tiles from Three.js: green elevation ramps for terrain, golden-amber for steep cliffs, turquoise for water, warm cream for roads, and simple roof colors (yellow, blue, red, terracotta, teal) over cream walls.

To avoid seams between tiles, I used a wave-front overlap approach. Each 1024x1024 tile overlaps its neighbours by 256px (25%) with a 40px cosine feather on the inner cut. Once tile (0, 0) is painted, its painted edge gets pasted onto tile (0, 1)'s whitebox so the next generation continues the roads, trees, and roofs across the border.

At 1.2m/px (768px stride per tile), covering Mauritius takes 1,320 land tiles. I started painting them directly with Nano Banana, moving north out of Port Louis over Le Pouce, Pieter Both, Baie du Tombeau, and Terre Rouge.

By tile 45 I hit the weekly generation quota with 1,275 tiles left to go. Not cool!

Those 45 tiles already covered most of the biomes on the island: dense downtown blocks, harbour docks, volcanic cliffs, forested ridges, sugarcane fields, rural villages, estuaries, and lagoons. That turned out to be enough to train a paired image-to-image LoRA. Thanks Google!

Gemini 4 Neon & Antigravity as my copilot

For this whole project, I used Neon exclusively to help me and guide me through all the steps, especially all the ML part as I am just a web developer who writes css for a living. I have been super impressed with it so far. Zero regrets for not using Opus in this project!

Training my first LoRA

Low Rank Adaptation, commonly referred to as LoRA, is where you use a base model and fine-tune it with your own dataset. That way the base "image" remains the same, and even if someone else wants to use your fine-tuned version, they don't have to download a huge model, they can simply get the base + your tensors. This is similar to how dependencies work in the web world or how certain Linux distros handle app installations.

I went with black-forest-labs/FLUX.2-klein-base-4B (Apache 2.0, ungated) because it supports paired image-to-image control conditioning natively and is small enough to train quickly.

Building the 224-pair dataset

With 45 painted tiles, feeding only raw whiteboxes isn't enough because during inference the model also has to continue from already-painted borders on the left, right, top, or bottom. I expanded the 45 tiles into 224 paired control-to-target 1024x1024 examples:

VariantWhat the control image showsPairs
Pure whiteboxRaw 3D semantic render only45
Real wave-frontActual neighbour strip composited during painting44
1-sided overlapSingle feathered edge (L, R, T, or B)45
2-sided L-cornerTwo adjacent painted edges45
3-sided U-lockThree painted edges framing the fourth45
Total224

Local MLX crash, then 23 minutes on Modal.com

First I tried training locally on my (supposedly beefy) M4 Max (36GB unified memory) with flux-2-swift-mlx. Even at 512px, paired image-to-image doubles the sequence length, swap filled up immediately, and Step 2 crashed with a SIGTRAP.

After searching online for options to run AI training and inference and browsing a few Reddit threads, I found Modal. They offer a generous $30/month credit on their free plan, which was more than enough for me! So I moved training there using ostris/ai-toolkit on a single A100-40GB:

network:
  type: "lora"
  linear: 32
  linear_alpha: 32
train:
  batch_size: 1
  steps: 500
  optimizer: "adamw8bit"
  lr: 1e-4
  noise_scheduler: "flowmatch"
  dtype: bf16
  ema_config:
    use_ema: true
    ema_decay: 0.99
model:
  name_or_path: "black-forest-labs/FLUX.2-klein-base-4B"
  arch: "flux2_klein_4b"

After 23 minutes and about $0.80, I had an 88MB .safetensors LoRA file. Here is how it did on four unseen validation tiles (flat 3D whitebox + neighbour border on the left, LoRA output on the right):

I also tried running the LoRA back on my Mac using the 4-step distilled variant of FLUX.2-klein-4B to avoid GPU costs. It ran, but 4-step inference lost spatial accuracy: turquoise lagoon water bled onto green lawns and grass colors washed out. Running 16 to 20 steps (CFG 4.0) on the base model on Modal (~16s per tile) kept the geometry locked 1:1.

Scaling to 1,320 tiles (and the bugs along the way)

I wrote a Modal script that loads FLUX.2-klein-base-4B once per container, merges the 88MB LoRA into BF16 weights, walks pending tiles in 4-connected BFS order (always picking tiles with the most painted neighbours first), and saves to a Modal Volume every 10 tiles. Running East and West chunks across two GPUs painted the island in nine regional batches.

Going from 45 tiles to 1,320 brought out a few bugs that never happened in Port Louis:

1. Writing "zero sky or horizon" actually caused sky horizons

On empty rural sugarcane tiles in the north, pale-blue sky strips and snowy mountain horizons started showing up along tile edges.

There were two reasons. My positive prompt literally had the words "zero sky or horizon" in it. Diffusion models don't handle negation, so mentioning sky and horizon in the positive prompt triggered sky tokens whenever the top edge of a tile was mostly flat green. On top of that, even after fixing a lower tile (r+1, c), any sky strip that used to sit in its unseen top 128px overlap margin had already been copied into the bottom of tile (r, c) above it.

To fix it, I scanned all 1,320 tiles for top and bottom sky strips, removed those words from the prompt, added an automatic reroll check, and repainted the 39 affected seam pairs top-down so each tile locked onto clean green terrain above it.

2. Fake offshore islands, false cliffs, and blue roofs near Curepipe

  • Offshore islands: coastal tiles with more than 50% open ocean kept hallucinating tiny islands in the sea. I added an open-ocean prompt branch and a whitebox coastline guard that leaves beaches and shallow reefs within 32px of real land alone while blending deep-sea hallucinations back into ocean wavelets.
  • Flat land turning into cliffs: if just one corner of a tile touched a mountain, the cliff prompt applied across flat sugarcane near the M3 motorway. Gating cliffs on the actual ratio of steep rock pixels in the whitebox (>= 3.8%) fixed it.
  • Color drift over 50+ hops: a long negative prompt made greens more and more neon as the wave-front moved south. Resetting the negative prompt to "" (to match training) and adding a gentle clamped CIE Lab color check anchored to the northern tiles stopped the drift. Before getting the clamping right, an aggressive Lab stretch briefly turned an urban strip south of Curepipe cobalt blue, so I had to repaint 55 tiles.

3. Missing reservoirs

When I zoomed out over the finished island, all the inland reservoirs were missing. Mare aux Vacoas, Midlands Dam, Bagatelle Dam, La Ferme, La Nicolière, and Ganga Talao were all painted as green fields because the 3D terrain binary only treats elevation <= 0m as water.

I already had 1m OpenStreetMap shoreline polygons for the seven main reservoirs from my mauritius-reservoirs project. I pulled the other five lakes (Ganga Talao, Eau Bleue, Tamarin Falls Reservoir, Valetta, and Bassin Blanc) from OSM, draped all 12 polygons onto the whitebox overlay underneath the road layer so dam-crest roads stayed visible, and repainted the 49 intersecting tiles using a highland mountain lake prompt (forested banks and stone dams instead of beaches and palm trees).

2x sharpening and keeping the viewer smooth

At 1.2m/px (768x768 cores), building outlines looked a bit soft at max zoom. Running a 2x pass with RealESRGAN_x4plus_anime_6B on Modal upgraded all 1,320 tiles to 1536x1536 (0.6m/px) in 16 minutes for about $0.56:

Loading 1,320 1536x1536 WebP tiles directly in the browser made zooming out sluggish, so I made a few viewer changes:

  • Built a 3-level viewport-culled LOD pyramid: one 4096x1552 full-island overview (1MB) when zoomed out, 106 4x4 super-tiles (1024x1024, 256px per tile) at mid zoom, and full 1536x1536 tiles once you zoom past 340px per tile, with an 85ms settle debounce so fast panning doesn't fire wasted downloads.
  • Feathered all 178 coastal boundary tiles using the whitebox shoreline distance masks so coastlines blend into the ocean without square tile corners.
  • Bundled a 12.8KB manifest into the page, skipped loading Three.js and the 3D terrain binaries on /anime, and uploaded all 1,427 WebP files (~580MB) to Cloudflare R2 with 1-year immutable caching.

The initial Port Louis view loads in 7 image requests (~2MB total) without loading Three.js.

Total Modal GPU cost

StageGPU TimeEst. Cost
LoRA training (500 steps, rank 32, A100-40GB)23 min~$0.80
Whole-island painting (1,320 tiles + repairs)~6.5 hrs~$15.20
All 12 reservoirs & lakes (49 tiles)16 min~$0.55
Whole-island 2x sharpening + repair upscales22 min~$0.74
Total~$17.29

That all stayed within Modal's $30/month free starter credits, so it cost $0 out of pocket.

Publishing to Hugging Face (first time as well!)

Since the 88MB LoRA adapter isn't tied to Mauritius, anyone with a 3D whitebox render of another city can run it on top of FLUX.2-klein-base-4B. I cleaned up the dataset captions, added the training config and inference script, and published everything on Hugging Face:

What's next

If you zoom in on Signal Mountain overlooking Port Louis, there's a small Easter egg carved into the cliff face: a Mauritian Giant Tortoise, Kestrel, and Dodo.

Next I want to revisit specific landmarks across the island and paint custom tiles for them: the statues at Ganga Talao, the red-roofed church at Cap Malheureux, Chamarel's Seven Coloured Earths, the wind turbines at Plaine des Roches, Pamplemousses Botanical Garden, Tamarin Falls, and SSR International Airport. But I will need to wait for nano-banana usage limits to reset next week to try that.. my custom LoRA cannot do landmarks.

You can check out the map at moris3d.ramgolam.com/anime.

Comments