Transform ordinary photos, portraits, and landscapes into stunning anime, Studio Ghibli, pop-art comic, and watercolor artwork. Features an ultra-modern Web Studio with an interactive Before/After split slider, a sleek Desktop GUI, a developer-first CLI & Python SDK, and a static Showcase Landing Page.
🌐 Live Showcase Website • ✨ Web Studio • 🖥️ Desktop GUI • ⚡ Python SDK • 🛡️ Security Matrix
| Style | Category | Description | Accent |
|---|---|---|---|
| 🔮 Studio Ghibli (Generative AI) | Generative AI | ChatGPT (DALL-E 3) & SDXL generative synthesis: reimagines scene with authentic Miyazaki character design. | #E84393 |
| 🎬 Studio Ghibli Pro | Artistic CV | Kuwahara painterly brushwork with warm afternoon sunlight grading and anti-aliased pencil inking. | #FF6B6B |
| 🍃 Hayao Anime | Neural AI | PyTorch AnimeGANv2 trained directly on Miyazaki anime frames. | #2ECC71 |
| ✨ Anime Portrait Soft | Neural AI | State-of-the-art neural anime stylization with expressive eyes and crisp face preservation. | #4ECDC4 |
| 🎨 Paprika Vibrant | Neural AI | Warm saturated cinematic cartoon look inspired by Satoshi Kon feature animation. | #FFB84D |
| 🌌 Shinkai Luminous | Neural AI | Makoto Shinkai high-contrast radiant lighting and glowing atmospheric accents. | #9B59B6 |
| 💥 Comic Pop Art | Artistic CV | Bold graphic novel inked contours with vibrant cell-shaded primary colors. | #E74C3C |
| 🎭 Watercolor Dream | Artistic CV | Soft pigment diffusion, gentle paper texture wash, and fluid color bleeding. | #A8D8EA |
| ✏️ Pencil & Charcoal | Artistic CV | Detailed graphite crosshatch line work with smooth continuous shading. | #95A5A6 |
| 🖍️ Colored Pencil | Artistic CV | Hand-drawn color sketch with textured paper grain and vibrant strokes. | #F39C12 |
| ⚡ Neon Cyberpunk | Artistic CV | Darkened cinematic scene with electric cyan and magenta glowing edges. | #00F0FF |
| 📺 Retro 90s TV Toon | Artistic CV | Nostalgic Saturday morning cartoon aesthetic with thick black ink borders. | #FD79A8 |
| 🎛️ Custom Pro Shader | Parametric | Real-time tunable parameters: line thickness, opacity, color count, saturation, and contrast. | #00CEC9 |
- 🌐 Modern Web Studio: Glassmorphism UI with interactive drag-and-drop, real-time Before/After comparison slider, live camera snapshot, and responsive dark/light themes.
- ✨ GitHub Pages Showcase (
docs/): Zero-dependency static landing page with an in-browser live HTML5 Canvas cartoon simulator. - 🖥️ Desktop GUI: Cross-platform responsive desktop app with side-by-side comparison, non-blocking asynchronous processing threads, and history gallery.
- ⚡ Neural & CV Engine: Combines deep learning (PyTorch Hub AnimeGANv2) and high-performance OpenCV algorithms for instant, offline-capable rendering.
- 👤 Face-Preserved Alignment: Smart face detection with elliptical feathered alpha masking to preserve identity on portrait photos.
- 📦 Batch Processing: Convert entire image directories in seconds and export directly as a ZIP archive.
- 🛡️ 50/50 Security & Fuzz Tests: Protected against decompression bombs, path traversal, Zip Slip, and NaN/Inf boundary vectors.
- 🐳 Docker Ready: Containerized deployment via Dockerfile and Docker Compose.
graph TD
A[Input: File / Webcam / Base64 / Stream] --> B[Security Validator & Clamping Layer]
B --> C{Face Alignment Enabled?}
C -->|Yes| D[OpenCV Haar Cascade Face Detector]
D --> E[Proportional 1.6x ROI Expansion]
E --> F[Generate Feathered Elliptical Alpha Mask]
C -->|No| G[Full Frame Ingestion]
F --> H{Selected Style Category}
G --> H
H -->|Neural AI| I[AnimeGANv2 Generator: face_paint / paprika / hayao / shinkai]
H -->|Artistic CV| J[Ghibli Pro / Pop Art / Watercolor / Neon / Pencil]
H -->|Parametric| K[Custom Shader: Line Inking + K-Means Color Quantization]
I --> L[Post-Processing & Local Contrast CLAHE]
J --> L
K --> L
L --> M{Face Composite Needed?}
M -->|Yes| N[Feathered Alpha Blend: Styled Face + Original Backdrop]
M -->|No| O[Final Output Image]
N --> O
Smooths flat surfaces while preserving sharp edge boundaries:
Calculates a 1.6x expanded centroid bounding box around detected facial coordinates and applies a continuous Gaussian fade to eliminate square seams:
The codebase includes an enterprise security test suite in tests/test_security.py:
| Protection Layer | Security Invariant | Status |
|---|---|---|
| Pixel Decompression Bomb | Pillow 50M limit + 40MP max dimension rejection | ✅ PASSED |
| Path Traversal Defense | Strips ../../, ..\Windows, null bytes \x00, special characters |
✅ PASSED |
| Zip Slip & Zip Bomb | Capped at 50 files / 200MB uncompressed buffer | ✅ PASSED |
| Adversarial Fuzzing | Handles NaN, +Infinity, -Infinity, negative slider values |
✅ PASSED |
| Corrupted Stream Resilience | Handles mutated bit-flipped byte streams and invalid Base64 | ✅ PASSED |
| HTTP Security Headers | X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN |
✅ PASSED |
| Thread Safety | Mutex-guarded neural model cache with zero race conditions | ✅ PASSED |
# Run the complete test suite:
pytest tests/ -v
# ===================== 50 passed in 56.43s =====================git clone https://github.com/AryanXCode646/cartoon-image-generator67.git
cd cartoon-image-generator67python -m venv .venv
# Windows (PowerShell)
.\.venv\Scripts\Activate.ps1
# Linux / macOS
source .venv/bin/activatepip install -r requirements.txt
# Or install in editable developer mode:
pip install -e .# Windows 1-click launcher:
run_web.bat
# Or via CLI:
python -m cartoonify webThen open your browser at http://127.0.0.1:8000.
# Windows 1-click launcher:
run_gui.bat
# Or via CLI:
python -m cartoonify guipython -m cartoonify process samples/sample_portrait.jpg -o output_ghibli.jpg --style ghibli_pro --strength 0.85python -m cartoonify process selfie.jpg -o selfie_anime.jpg --style anime_soft --face-alignpython -m cartoonify batch ./my_vacation_photos -o ./cartoons --style comic_poppython -m cartoonify list-stylesfrom cartoonify import CartoonEngine
import cv2
# Initialize the engine (auto-selects CUDA GPU or CPU)
engine = CartoonEngine()
# 1. ChatGPT-Grade Generative AI Studio Ghibli Synthesis
engine.process_file(
"portrait.jpg",
"ghibli_chatgpt_art.jpg",
style="ghibli_generative",
custom_params={"openai_api_key": "your-openai-api-key"}
)
# 2. Local Neural Hayao Miyazaki Checkpoint (AnimeGANv2)
engine.process_file(
"portrait.jpg",
"ghibli_hayao_art.jpg",
style="hayao",
use_face_align=True
)
# 3. High-Speed Kuwahara Painterly Filter (100% Offline)
engine.process_file(
"portrait.jpg",
"ghibli_kuwahara.jpg",
style="ghibli_pro",
strength=0.85
)# Start Web Studio in container:
docker-compose up -d
# Open in browser:
http://localhost:8000| Launcher Script | Description |
|---|---|
run_web.bat |
Launches FastAPI server & opens Web Studio in default browser |
run_gui.bat |
Launches the modern Tkinter Desktop GUI |
run_cli.bat |
Opens interactive CLI helper |
run_tests.bat |
Executes the 50/50 Pytest suite |
run_showcase_website.bat |
Opens the static showcase website locally |
# Run all 50 unit and security tests:
pytest tests/ -v
# Run with coverage:
pytest --cov=cartoonify tests/Automated GitHub Actions CI runs on every push across Ubuntu (Linux), Windows, and macOS.
Distributed under the MIT License. See LICENSE for more details.