Skip to main content

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

PyPI Python License CI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanana-0.1.0.tar.gz (440.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sanana-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (531.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Hashes for sanana-0.1.0.tar.gz
Algorithm Hash digest
SHA256 574a7db9d60b1d27c6ba1bea9c837d5c6d424dc26a1a82483dbcf92c4d1e4470
MD5 020a76bc1a469bf805c683464e48aaf2
BLAKE2b-256 e36ee6cc74334124405e03bb56da3d0b09ed02c619f8f7a721280a013257801e

See more details on using hashes here.

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

Hashes for sanana-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ae57222b245f7f94a0f538a1d6739d7fd10b468a0d5b148b999f13e36649c6a
MD5 025112fac2ebc7c6e3de10e495b32f08
BLAKE2b-256 3358e4b8eeecdf4475ac7a771313e9d435767ad8aa2bb3620f38003075c5f46f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page