Skip to content
ANKARAHAMSAPublic

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽจ TOONIFY

Turn your photo into stunning cartoon art โ€” powered by Stable Diffusion

Live Demo Backend License

TOONIFY Banner React FastAPI Vercel Render


โœจ Features

  • ๐Ÿ–ผ๏ธ Upload any photo โ€” portraits, selfies, group shots
  • ๐ŸŽจ 12 unique art styles โ€” Disney, Anime, Ghibli, Arcane, Pixar, Comic, Van Gogh, Simpsons, Cyberpunk, Watercolor, Claymation, Pencil Sketch
  • ๐ŸŽš๏ธ Style Strength Slider โ€” fine-tune from subtle (40%) to full transformation (90%)
  • ๐Ÿ‘ค IP-Adapter Face Lock โ€” preserve face identity across styles
  • โš–๏ธ Before/After Compare Mode โ€” drag to reveal the transformation
  • ๐Ÿ”ฎ Custom LoRA styles โ€” Arcane Painterly & 3D Claymation trained styles
  • ๐ŸŒ Fully deployed โ€” Vercel frontend + Render backend

๐Ÿ–ฅ๏ธ Live App

Frontend: toonify-studio.vercel.app
API Health: toonify-backend-8mup.onrender.com/health
API Docs: toonify-backend-8mup.onrender.com/docs

โš ๏ธ The backend runs on Render's free tier โ€” first request after inactivity may take ~50s to wake up.


๐ŸŽจ Art Styles

Style Emoji Description
Modern Disney ๐Ÿฐ Vibrant, expressive Disney animation
Anime โ›ฉ๏ธ Clean Makoto Shinkai aesthetic
Studio Ghibli ๐ŸŒฟ Soft, painterly Miyazaki-style
Arcane Painterly ๐Ÿ”ฎ Custom LoRA โ€” dramatic neon lighting
3D Claymation ๐Ÿงฑ Custom LoRA โ€” tactile clay texture
Pixar 3D โœจ Warm Pixar-style 3D render
Comic Book ๐Ÿ’ฅ Bold Marvel comic ink outlines
Van Gogh ๐ŸŒป Post-impressionist swirling brushstrokes
Simpsons ๐ŸŸก Classic yellow skin flat cartoon
Cyberpunk ๐ŸŒ† Neon-lit blade runner atmosphere
Watercolor ๐ŸŽจ Soft flowing paper watercolor
Pencil Sketch โœ๏ธ Fine graphite crosshatching

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    TOONIFY Stack                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   FRONTEND  โ”‚     BACKEND      โ”‚    INFERENCE           โ”‚
โ”‚   Vercel    โ”‚     Render       โ”‚  HuggingFace Spaces    โ”‚
โ”‚             โ”‚                  โ”‚  (optional GPU)        โ”‚
โ”‚  React 18   โ”‚   FastAPI 0.111  โ”‚   Gradio + SD          โ”‚
โ”‚  Vite 5     โ”‚   Uvicorn        โ”‚   nitrosocke/mo-di     โ”‚
โ”‚  CSS3       โ”‚   Pillow (mock)  โ”‚   T4 GPU               โ”‚
โ”‚             โ”‚   gradio_client  โ”‚                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†• /api/* proxy              โ†• HF_SPACES_URL
    vercel.json rewrites         gradio_client.predict()

Data Flow:

User Photo โ†’ Vercel Frontend โ†’ Render Backend โ†’ HF Spaces (GPU) โ†’ Cartoon Image
                                     โ†“ (if HF unavailable)
                               Mock PIL filter โ†’ Cartoon Image

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 18 + Vite 5 โ€” fast SPA
  • Vanilla CSS โ€” custom design system with glassmorphism, dark mode
  • Google Fonts โ€” Outfit + Inter
  • Axios โ€” API client with upload progress

Backend

  • FastAPI โ€” async Python REST API
  • Uvicorn โ€” ASGI server
  • Pillow โ€” mock cartoon filters (no GPU)
  • diffusers โ€” Stable Diffusion img2img (GPU mode)
  • gradio_client โ€” HF Spaces proxy client

AI/ML

  • Stable Diffusion 1.5 โ€” base model
  • nitrosocke/mo-di-diffusion โ€” Disney-style fine-tune
  • IP-Adapter โ€” face identity preservation
  • Custom LoRA โ€” Arcane & Claymation styles (trained in Colab)

Infra

  • Vercel โ€” frontend hosting (CDN edge)
  • Render โ€” backend hosting (free tier)
  • HuggingFace Spaces โ€” GPU inference (optional T4)
  • GitHub Actions โ€” auto-deploy on push

๐Ÿš€ Local Development

Prerequisites

  • Node.js 20+
  • Python 3.12+
  • Git

1. Clone the repo

git clone https://github.com/ANKARAHAMSA/TOONIFY.git
cd TOONIFY

2. Start the backend (Mock Mode โ€” no GPU needed)

cd backend
python -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install -r requirements.txt
MOCK_MODE=true uvicorn main:app --reload
# Backend running at http://localhost:8000

3. Start the frontend

cd frontend
npm install
npm run dev
# Frontend running at http://localhost:5173

Open http://localhost:5173 โ€” the Vite proxy forwards /api/* to the backend automatically.


๐Ÿ”ง Environment Variables

Backend (Render / local)

Variable Default Description
MOCK_MODE false Use PIL filters instead of SD (no GPU)
MODEL_PATH ./mo-di-diffusion HuggingFace model ID or local path
USE_IP_ADAPTER false Enable IP-Adapter face lock
IP_ADAPTER_SCALE 0.7 Face lock strength (0.0โ€“1.0)
HF_SPACES_URL `` HF Space ID for GPU inference proxy
ALLOWED_ORIGINS * CORS allowed origins
PORT 8000 Server port

Frontend (Vercel)

Variable Description
VITE_API_BASE Override API base URL (optional)

๐ŸŒ Deployment

Frontend โ†’ Vercel

  1. Import ANKARAHAMSA/TOONIFY on vercel.com
  2. Set Root Directory โ†’ frontend
  3. Click Deploy โ€” auto-detects Vite

Backend โ†’ Render

  1. New Web Service โ†’ connect ANKARAHAMSA/TOONIFY
  2. Language: Python | Root Directory: backend
  3. Build Command: pip install -r requirements.txt
  4. Start Command: uvicorn main:app --host 0.0.0.0 --port $PORT
  5. Add env vars: MOCK_MODE=true, PYTHON_VERSION=3.12.6

Real GPU Inference โ†’ HuggingFace Spaces

  1. Create new Space at huggingface.co/new-space
  2. Upload spaces/app.py, spaces/requirements.txt, spaces/README.md
  3. Set hardware to T4 Small
  4. Add HF_SPACES_URL=your-username/toonify to Render env vars

๐Ÿง  Custom LoRA Training

Train your own Arcane-style LoRA using the provided Colab notebook:

Open In Colab

Training images: training_images/arcane/ (30 Arcane-style 512ร—512 PNGs)
Trigger word: arcane_toonify style
Base model: runwayml/stable-diffusion-v1-5


๐Ÿ“ Project Structure

TOONIFY/
โ”œโ”€โ”€ frontend/                  # React + Vite app
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx            # Main app with state management
โ”‚   โ”‚   โ”œโ”€โ”€ api.js             # Axios API wrapper
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ StrengthSlider.jsx   # Style strength control
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ CompareSlider.jsx    # Before/After comparison
โ”‚   โ”‚   โ””โ”€โ”€ index.css          # Design system + animations
โ”‚   โ””โ”€โ”€ vercel.json            # Vercel rewrite config
โ”‚
โ”œโ”€โ”€ backend/                   # FastAPI backend
โ”‚   โ”œโ”€โ”€ main.py                # API routes
โ”‚   โ”œโ”€โ”€ pipeline.py            # SD pipeline + 12 styles + HF client
โ”‚   โ”œโ”€โ”€ models.py              # Pydantic schemas
โ”‚   โ”œโ”€โ”€ requirements.txt       # Pinned dependencies
โ”‚   โ””โ”€โ”€ runtime.txt            # Python 3.12.6
โ”‚
โ”œโ”€โ”€ spaces/                    # HuggingFace Spaces inference app
โ”‚   โ”œโ”€โ”€ app.py                 # Gradio SD inference app
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ””โ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ notebooks/
โ”‚   โ””โ”€โ”€ lora_training_complete.ipynb  # 9-cell LoRA training
โ”‚
โ”œโ”€โ”€ training_images/
โ”‚   โ””โ”€โ”€ arcane/               # 30 Arcane training images + metadata
โ”‚
โ””โ”€โ”€ scripts/
    โ””โ”€โ”€ generate_placeholders.py

๐Ÿ›ฃ๏ธ Roadmap

  • Stable Diffusion img2img pipeline
  • 12 art styles (7 base + 2 LoRA + 3 new)
  • IP-Adapter face identity preservation
  • Style Strength Slider
  • Before/After Compare Mode
  • Vercel + Render deployment
  • HuggingFace Spaces GPU inference
  • Custom LoRA training pipeline
  • User gallery (Firebase)
  • Social sharing
  • Credits / monetization (Stripe)
  • Mobile app (React Native)
  • Video cartoonization

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


Built with โค๏ธ using Stable Diffusion, FastAPI, and React
toonify-studio.vercel.app

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages