A two-part setup that turns a free Google Colab GPU into a personal Animagine XL 4.0 render server, with a web app you run on your laptop to control it from any device on your wifi.
Model: cagliostrolab/animagine-xl-4.0
[Phone / tablet / laptop] --wifi--> [Your laptop: server.py] --internet--> [Colab: colab_backend.py]
(browser UI) (proxy + static files) (ngrok tunnel) (GPU, the model)
colab_backend.py runs in Google Colab. It loads Animagine XL 4.0 on
the Colab GPU and exposes it as an HTTP API, tunneled to a public URL with
ngrok.frontend/server.py runs on your laptop. It serves the web app to
every device on your wifi network and forwards generation requests to the
Colab backend, so the browser never talks to Colab directly.frontend/static/ is the web app itself: prompt box with danbooru tag
autocomplete, batch size, resolution/aspect ratio, advanced sampling
settings, and a masonry gallery with a slideshow-style viewer.frontend/data/build_tag_index.py + frontend/tag_lookup.py are
the tag autofill: a one-time script turns a danbooru tags.csv export
into a local SQLite index, and the frontend queries it directly — no
internet call, no live Danbooru API, at request time.colab_backend.py into a single cell.NGROK_AUTH_TOKEN field near the top of the script.API_KEY; if you leave it blank, one is
generated for you.The autofill dropdown is powered entirely by a local SQLite index built from a danbooru tag export — no network calls, no rate limits.
tags.csv in frontend/data/. Needs at least the columns name,
post_count, category, is_deprecated.tag_aliases.csv in the same folder — columns
antecedent_name, consequent_name — so searching an old/renamed tag
still resolves to the current one (shown as old name → current name in
the dropdown).cd frontend/data
python build_tag_index.py
This produces tags.db (took ~45s / ~900k tags on a full danbooru
export). Re-run it any time you refresh tags.csv. Artist tags
(category 1) and deprecated tags are excluded from the index by design.Requires Python 3.9+.
cd frontend
pip install -r requirements.txt
python server.py
The terminal prints two URLs:
http://127.0.0.1:5000 — for this laptop onlyhttp://<your-lan-ip>:5000 — open this one on your phone, tablet, or any
other device connected to the same wifi networkold → current. Press
Tab or Enter to instantly complete the top prediction, use ↑/↓ to
pick another, or click/tap any suggestion. Whatever's shown with spaces
gets inserted with underscores (purple eyes → purple_eyes), matching
danbooru's actual tag format.frontend/data/tags.csv and the generated frontend/data/tags.db are not
included in this project — they're large (hundreds of MB) and specific to
whichever danbooru export you're using. Supply your own tags.csv and run
the build step above.colab_backend.py and update the URL
in the frontend's settings (ngrok gives a new URL each run on the free
tier).X-API-Key check exists because ngrok URLs are public — without it,
anyone who found your URL could use your GPU time. Don't share the printed
API key outside your own devices.2 commits
Python
41.2%
JavaScript
30.6%
CSS
19.5%
HTML
8.7%
A two-part setup that turns a free Google Colab GPU into a personal Animagine XL 4.0 render server, with a web app you run on your laptop to control it from any device on your wifi.
Model: cagliostrolab/animagine-xl-4.0
[Phone / tablet / laptop] --wifi--> [Your laptop: server.py] --internet--> [Colab: colab_backend.py]
(browser UI) (proxy + static files) (ngrok tunnel) (GPU, the model)
colab_backend.py runs in Google Colab. It loads Animagine XL 4.0 on
the Colab GPU and exposes it as an HTTP API, tunneled to a public URL with
ngrok.frontend/server.py runs on your laptop. It serves the web app to
every device on your wifi network and forwards generation requests to the
Colab backend, so the browser never talks to Colab directly.frontend/static/ is the web app itself: prompt box with danbooru tag
autocomplete, batch size, resolution/aspect ratio, advanced sampling
settings, and a masonry gallery with a slideshow-style viewer.frontend/data/build_tag_index.py + frontend/tag_lookup.py are
the tag autofill: a one-time script turns a danbooru tags.csv export
into a local SQLite index, and the frontend queries it directly — no
internet call, no live Danbooru API, at request time.colab_backend.py into a single cell.NGROK_AUTH_TOKEN field near the top of the script.API_KEY; if you leave it blank, one is
generated for you.The autofill dropdown is powered entirely by a local SQLite index built from a danbooru tag export — no network calls, no rate limits.
tags.csv in frontend/data/. Needs at least the columns name,
post_count, category, is_deprecated.tag_aliases.csv in the same folder — columns
antecedent_name, consequent_name — so searching an old/renamed tag
still resolves to the current one (shown as old name → current name in
the dropdown).cd frontend/data
python build_tag_index.py
This produces tags.db (took ~45s / ~900k tags on a full danbooru
export). Re-run it any time you refresh tags.csv. Artist tags
(category 1) and deprecated tags are excluded from the index by design.Requires Python 3.9+.
cd frontend
pip install -r requirements.txt
python server.py
The terminal prints two URLs:
http://127.0.0.1:5000 — for this laptop onlyhttp://<your-lan-ip>:5000 — open this one on your phone, tablet, or any
other device connected to the same wifi networkold → current. Press
Tab or Enter to instantly complete the top prediction, use ↑/↓ to
pick another, or click/tap any suggestion. Whatever's shown with spaces
gets inserted with underscores (purple eyes → purple_eyes), matching
danbooru's actual tag format.frontend/data/tags.csv and the generated frontend/data/tags.db are not
included in this project — they're large (hundreds of MB) and specific to
whichever danbooru export you're using. Supply your own tags.csv and run
the build step above.colab_backend.py and update the URL
in the frontend's settings (ngrok gives a new URL each run on the free
tier).X-API-Key check exists because ngrok URLs are public — without it,
anyone who found your URL could use your GPU time. Don't share the printed
API key outside your own devices.2 commits
Python
41.2%
JavaScript
30.6%
CSS
19.5%
HTML
8.7%