Turn your photos into Ghibli-style illustrations in one command
English | ๐ ไธญๆๆๆกฃ
sanana is a local, privacy-first image editor that transforms ordinary photos into cartoon-style illustrations โ think Studio Ghibli, anime, or hand-drawn aesthetics. It runs entirely on your own machine using CPU only, with no image ever leaving your computer.
โ ๏ธ Disclaimer:sananais a third-party, community-driven Python wrapper โ it is not an official product of Alibaba or the MNN team. The underlying inference engine (MNN) and the diffusion model (MNN-Sana-Edit-V2) are developed by Alibaba; this repository only provides a convenient CLI and Python API around them.๐ Prompt limitation: The model was trained with a fixed prompt, so custom
--promptvalues have no effect on the output style. The model only knows one style (cartoon/Ghibli-like), and changing the prompt will not switch to a different aesthetic.
Under the hood, sanana is powered by Alibaba MNN, a high-performance deep-learning inference engine, and the MNN-Sana-Edit-V2 diffusion model. The model is distilled to produce high-quality results in just 10 inference steps, making it fast enough for everyday use on regular laptops and desktops. On first run, the ~1.2GB model is downloaded automatically from ModelScope โ after that, everything works offline.
sanana is also the Python desktop companion to the official MNN Chat mobile apps: the same Sana model runs on both Android and iOS, so you can edit photos on your phone or computer with identical results.
# One-shot โ run without installing anything (requires uv)
uvx sanana photo.jpg
# Or install permanently with uv
uv tool install sanana
sanana photo.jpg| Original | ๐ช sanana Magic |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
# Run once without installing (requires uv)
uvx sanana photo.jpg
# Or install permanently
uv tool install sanana
sanana photo.jpgThe model (~1.2GB) will be downloaded automatically on first run.
| ๐จ | Cartoon Style Transfer | Photos โ Ghibli/anime illustrations in one command |
|---|---|---|
| ๐ | Fully Local | No internet, no cloud upload, absolute privacy |
| ๐ | Python Native | pybind11 C++ extension, inference inside Python process |
| ๐ป | CPU-only | MNN high-performance engine, runs on ordinary machines |
| โก | 10 Steps | MNN-Sana-Edit-V2 knowledge-distilled model, high quality with few steps |
| ๐ | Fixed Prompt | Model trained on a single style; custom prompts do not change the output |
The same MNN-Sana-Edit-V2 model also runs on mobile devices:
- Android: Download MNN Chat APK or Google Play, then download the Sana model from the in-app model market
- iOS: MNN LLM Chat โ build from source or check the App Store for "MNN Chat"
# Run once without installing
uvx sanana photo.jpg
# Or install permanently
uv tool install sananapip install sananaThis automatically clones and builds MNN (requires git, cmake, C++ compiler).
git clone https://github.com/vra/sanana.git
cd sanana
uv sync
source .venv/bin/activate
sanana photo.jpg# Minimal
sanana photo.jpg
# Custom output
sanana photo.jpg -o output.jpg
# Custom prompt (note: has no effect on output style)
sanana photo.jpg --prompt "Ghibli style"
# Full args
sanana photo.jpg \
-o out.jpg \
--prompt "Convert to Ghibli style" \
--steps 10 \
--seed 42 \
--width 512 \
--height 512| Argument | Description | Default |
|---|---|---|
input |
Input image path | Required |
-o, --output |
Output path | input_stem_cartoon.jpg |
--prompt |
Style prompt | Convert to a cartoon-style illustration |
--steps |
Inference steps | 10 |
--seed |
Random seed | 42 |
--width/--height |
Output size | 512x512 |
from sanana import edit_image
# One-shot
edit_image("./photo.jpg", steps=10, seed=42)from sanana import SanaEditor
# Advanced: reuse model for batch processing
editor = SanaEditor(backend="cpu", memory_mode=2)
editor.load()
for img in ["a.jpg", "b.jpg", "c.jpg"]:
editor.run(
input_image=img,
output_image=img.replace(".jpg", "_cartoon.jpg"),
steps=10,
)โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Python Layer โ
โ sanana (CLI / API) โ
โ โ import โ
โ sanana._sana_diffusion โ
โ (pybind11 C++ Extension) โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ง C++ Layer (MNN) โ
โ SanaLlm โโโ SanaDiffusion โโโ Image โ
โ (Text Encode) (Flow Matching Denoise) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Text Encoding: Qwen3-0.6B LLM processes the prompt
- Feature Bridging: Connector โ Projector maps to DiT space
- VAE Encode: Input image โ Latent (img2img)
- DiT Denoise: Euler sampling + Flow Shift, 10 steps
- VAE Decode: Latent โ Final image
Apple MacBook Pro M3 (CPU, 512ร512, 10 steps):
| Stage | Time |
|---|---|
| LLM Text Encoding | ~1.5 s |
| VAE Encode | ~3 s |
| DiT Denoise (10 steps) | ~22 s |
| VAE Decode | ~5 s |
| Total | ~32 s |
| Platform | Status | Notes |
|---|---|---|
| macOS (Apple Silicon / Intel) | โ Supported | Best performance on M1/M2/M3 |
| Linux (x86_64 / ARM64) | โ Supported | Tested on Ubuntu 22.04+ |
| Windows (x86_64) | Requires Visual Studio + OpenCV, CI unstable |
- Python: 3.10+
- Compiler: Clang/GCC/MSVC (C++17)
- Tools: git, cmake
Q: MNN not found during install?
A: setup.py auto-clones and builds MNN. Just ensure git, cmake, and a C++ compiler are installed.
Q: First run is slow?
A: The model (~1.2GB) is downloaded on first use. Subsequent runs are fast.
Q: GPU support?
A: CPU by default. Use backend="metal" for Metal (macOS), requires MNN built with GPU flags.
Q: Commercial use?
A: Code is Apache-2.0. Model files follow the original publisher's license.
Issues and PRs welcome! See CONTRIBUTING.md.
See CHANGELOG.md.
Code: Apache-2.0.
Model: MNN-Sana-Edit-V2 belongs to its original publisher.
If this project helps you, please give it a โญ Star!







