Local cartoon-style image editor powered by MNN-Sana-Edit-V2
Project description
๐จ sanana
Turn your photos into Ghibli-style illustrations in one command
Local ยท Private ยท CPU-only ยท No GPU needed
English | ๐ ไธญๆๆๆกฃ
โจ Showcase
| Original | ๐ช sanana Magic |
๐ One-Liner Start
# Install once
pip install sanana
sanana photo.jpg
# Or run without installing (requires uv)
uvx sanana photo.jpg
The model (~1.2GB) will be downloaded automatically on first run.
๐ฅ Highlights
| ๐จ | Cartoon Style Transfer | Photos โ Ghibli/anime illustrations |
|---|---|---|
| ๐ | 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 | Knowledge-distilled model, high quality with few steps |
| ๐ฆ | Truly Ready-to-Use | pip install handles all dependencies automatically |
๐ฆ Installation
Option 1: pip (Recommended)
pip install sanana
This automatically clones and builds MNN (requires git, cmake, C++ compiler).
Option 2: From Source
git clone https://github.com/vra/sanana.git
cd sanana
uv pip install -e ".[dev]"
๐ฎ Usage
CLI
# Minimal
sanana photo.jpg
# Custom output
sanana photo.jpg -o output.jpg
# Custom prompt
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 |
Python API
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,
)
โ๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ 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
๐ฅ๏ธ Performance
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 |
๐งฉ Requirements
| 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) | โ ๏ธ Experimental | Requires Visual Studio + OpenCV, CI unstable |
- Python: 3.10+
- Compiler: Clang/GCC/MSVC (C++17)
- Tools: git, cmake
โ FAQ
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.
๐ค Contributing
Issues and PRs welcome! See CONTRIBUTING.md.
๐ Changelog
See CHANGELOG.md.
๐ License
Code: Apache-2.0.
Model: MNN-Sana-Edit-V2 belongs to its original publisher.
If this project helps you, please give it a โญ Star!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sanana-0.1.0.tar.gz.
File metadata
- Download URL: sanana-0.1.0.tar.gz
- Upload date:
- Size: 440.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
574a7db9d60b1d27c6ba1bea9c837d5c6d424dc26a1a82483dbcf92c4d1e4470
|
|
| MD5 |
020a76bc1a469bf805c683464e48aaf2
|
|
| BLAKE2b-256 |
e36ee6cc74334124405e03bb56da3d0b09ed02c619f8f7a721280a013257801e
|
File details
Details for the file sanana-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: sanana-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 531.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae57222b245f7f94a0f538a1d6739d7fd10b468a0d5b148b999f13e36649c6a
|
|
| MD5 |
025112fac2ebc7c6e3de10e495b32f08
|
|
| BLAKE2b-256 |
3358e4b8eeecdf4475ac7a771313e9d435767ad8aa2bb3620f38003075c5f46f
|