Skip to content
aashish254Public

About

🎬 Autonomous AI Studio for Manhwa & Webtoon Recaps β€” Vision Pipeline (YOLOv8 + Magi v2), Multi-Voice TTS & Video Synthesis

Topics

Resources

Contributing

Security policy

Stars

54 stars

Watchers

1 watching

Forks

Repository files navigation

AniFlow Logo

AniFlow

Turn manhwa & webtoon chapters into narrated recap videos β€” fully automated.

Quick Start Python License Platform

AniFlow web UI
The AniFlow web UI β€” pick a recap mode and run the pipeline end to end in your browser.

Recap clips rendered by AniFlow
Real output: frames from clips rendered by both pipelines β€” AI narration on clean panels, dialogue read with the original speech bubbles.


AniFlow downloads manhwa/webtoon chapters, detects and crops panels using YOLO, extracts speech-bubble text, generates AI narration, converts it to speech, and renders video clips β€” all through a browser-based UI.

✨ Features

  • 🌐 Web Scraper β€” download chapters from manhuaus, manhwatop, MangaDex, and more
  • πŸ” YOLO Panel Detection β€” custom-trained models detect panels and speech bubbles
  • 🧹 Text Removal β€” automatically clean speech bubbles from art panels
  • πŸ€– AI Narration β€” local (Ollama) or cloud (Gemini / Claude) narration
  • πŸŽ™οΈ Multi-TTS β€” Edge TTS (free), Kokoro (local), or ElevenLabs (cloud)
  • 🎬 Video Rendering β€” Ken Burns animation, blur backgrounds, BGM, watermarks
  • πŸ‘₯ Character Casting β€” import from MyAnimeList or scan faces from chapters
  • πŸ“¦ Batch Mode β€” process dozens of chapters unattended

Two Pipelines

Dialogue Recap Narrated Recap
Panels Original panels with speech bubbles Clean art panels (bubbles removed)
Audio Extracted dialogue read aloud AI-written YouTube-style recap narration
Best for Letting the original dialogue shine YouTube story recaps

πŸ“‚ See it in action! Check the example_output/ folder for sample clips from both modes.

πŸŽ₯ Video Tutorials

Tutorial Link
πŸ’¬ Dialogue Recap β€” Single Chapter Watch on YouTube
πŸ’¬ Dialogue Recap β€” Batch Mode (50+ Chapters) Watch on YouTube
πŸŽ™οΈ Narrated Recap β€” Automatic Pipeline Watch on YouTube
πŸŽ™οΈ Narrated Recap β€” Batch Mode (Full Series) Watch on YouTube

πŸ“‹ Requirements

Dependency Purpose Install
Python 3.10 – 3.12 Runtime python.org
FFmpeg Video/audio processing brew install ffmpeg (macOS) Β· sudo apt install ffmpeg (Linux) Β· ffmpeg.org (Windows)
Ollama Local AI narration & text extraction ollama.com β€” or use 9router for narration only
~10 GB disk Python env + model weights β€”

GPU recommended but not required. Apple Silicon Macs and NVIDIA GPUs will significantly speed up panel detection and Kokoro TTS.


πŸš€ Quick Start

Option A: One-Command Setup (Recommended)

git clone https://github.com/aashish254/Aniflow.git
cd AniFlow
chmod +x setup.sh
./setup.sh

The setup script will check dependencies, create a virtual environment, install packages, pull Ollama models, and start the app.

Option B: Manual Setup

# 1. Clone the repository
git clone https://github.com/aashish254/Aniflow.git
cd AniFlow

# 2. Create a virtual environment (Python 3.12 recommended)
py -3.12 -m venv venv             # Windows
# python3 -m venv venv            # macOS / Linux

# 3. Activate virtual environment
# Windows (PowerShell):
.\venv\Scripts\Activate.ps1
# macOS / Linux:
# source venv/bin/activate

# 4. Install Python dependencies (~10-20 min, torch is large)
pip install --upgrade pip
pip install -r requirements.txt

# 5. Configure 9router (Alternative to Ollama)
# If you use 9router, set these environment variables before running:
# Windows (PowerShell):
# $env:USE_NINE_ROUTER="1"
# $env:NINE_ROUTER_HOST="http://127.0.0.1:20128"
# $env:VISION_MODEL="Free-Tier"
# $env:WRITER_MODEL="Free-Tier"
# $env:TEXT_WRITER_MODEL="Free-Tier"

# 6. Pull Ollama models (Skip if using 9router)
# ollama pull qwen2.5vl:3b
# ollama pull qwen2.5:14b

# 7. Run the app
python app.py

# 8. Open UI in browser:
# http://localhost:8080

Windows Setup

# 1. Clone and enter the project
git clone https://github.com/aashish254/Aniflow.git
cd AniFlow

# 2. Run the setup script
setup.bat

Or follow the manual steps above using venv\Scripts\activate instead.

9router (alternative to Ollama)

9router exposes models through an OpenAI-compatible local endpoint, so you can run the narrator without pulling multi-gigabyte Ollama models. It replaces Ollama for AI narration only β€” speech-bubble text extraction still needs Ollama.

Start 9router first (default http://127.0.0.1:20128), then point AniFlow at it:

# Windows (PowerShell)
.\venv\Scripts\Activate.ps1

$env:USE_NINE_ROUTER = "1"
$env:NINE_ROUTER_HOST = "http://127.0.0.1:20128"
$env:VISION_MODEL = "Free-Tier"
$env:WRITER_MODEL = "Free-Tier"
$env:TEXT_WRITER_MODEL = "Free-Tier"

# Only if your 9router instance requires one:
# $env:NINE_ROUTER_API_KEY = "your_key"

python app.py
# macOS / Linux
source venv/bin/activate

export USE_NINE_ROUTER=1
export NINE_ROUTER_HOST=http://127.0.0.1:20128
export VISION_MODEL=Free-Tier
export WRITER_MODEL=Free-Tier
export TEXT_WRITER_MODEL=Free-Tier

python app.py

The same variables can live in .env instead β€” uncomment the 9router block in .env.example. Once USE_NINE_ROUTER=1 is set, the app's model health check queries 9router's /v1/models endpoint instead of Ollama's /api/tags.


🎬 How to Use

Narrated Recap (Recommended)

  1. Source β€” Paste a manhwa URL β†’ Analyze β†’ pick chapters β†’ Download (or point to a local folder of images)
  2. Cast (optional) β€” Import characters from MyAnimeList, or scan chapter faces and assign names. The narrator uses real names ("Jin-Woo…") instead of "the dark-haired guy."
  3. Stitch β€” Stitch β†’ Detect (bubble panels) β†’ Crop β†’ Stitch β†’ Detect (art panels) β†’ Crop. Boxes are editable β€” drag, resize, or draw new ones.
  4. Review β€” Check cropped panels; delete junk or re-crop.
  5. Extract β€” AI reads speech-bubble text.
  6. Narrate β€” Choose your AI backend:
    • πŸ¦™ Ollama (local) β€” free & offline. qwen2.5vl:7b (vision) or qwen2.5:14b (text-only).
    • ✨ Gemini API β€” paste multiple API keys (auto-rotation on quota). Free keys at aistudio.google.com.
    • πŸ€– Claude API β€” single key.
  7. Review Text β€” Edit any narration line or re-narrate individual panels.
  8. Audio β€” TTS with Edge (free), Kokoro (local), or ElevenLabs.
  9. Video β€” Renders clips with Ken Burns animation, blur backgrounds, BGM.
  10. Review Clips / Sort Clips β€” Preview, download, or batch-merge.

Dialogue Recap

Same flow minus the cast/narrate steps β€” extracted dialogue becomes the audio, panels keep their original speech bubbles.

Batch Mode

Download chapters 1–68, enable Batch Mode, hit Run Full Batch β€” every step runs across all chapters automatically. Progress is streamed live.


πŸ“ Project Structure

AniFlow/
β”œβ”€β”€ app.py                  # Flask web app + API routes
β”œβ”€β”€ config.py               # All configuration & path settings
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ setup.sh / setup.bat    # One-command setup scripts
β”œβ”€β”€ start.sh                # Quick-start script (macOS/Linux)
β”‚
β”œβ”€β”€ pipeline/               # Core processing modules
β”‚   β”œβ”€β”€ web_scraper.py      #   Chapter downloading (multi-site)
β”‚   β”œβ”€β”€ stitcher.py         #   Image stitching
β”‚   β”œβ”€β”€ panel_extractor_yolo.py  # YOLO panel detection
β”‚   β”œβ”€β”€ cropper.py          #   Panel cropping
β”‚   β”œβ”€β”€ text_extractor.py   #   OCR / text extraction
β”‚   β”œβ”€β”€ text_remover.py     #   Speech bubble cleaning
β”‚   β”œβ”€β”€ narrator.py         #   Local AI narration (Ollama)
β”‚   β”œβ”€β”€ gemini_narrator.py  #   Cloud narration (Gemini API)
β”‚   β”œβ”€β”€ scene_narrator.py   #   Scene-level narration
β”‚   β”œβ”€β”€ tts_engine.py       #   Edge TTS engine
β”‚   β”œβ”€β”€ kokoro_tts.py       #   Kokoro local TTS
β”‚   β”œβ”€β”€ elevenlabs_tts.py   #   ElevenLabs cloud TTS
β”‚   β”œβ”€β”€ compositor.py       #   Video rendering
β”‚   β”œβ”€β”€ orchestrator.py     #   Pipeline orchestration
β”‚   β”œβ”€β”€ cast_system.py      #   Character management
β”‚   β”œβ”€β”€ character_builder.py #  Face detection & grouping
β”‚   β”œβ”€β”€ mal_character_importer.py # MAL character import
β”‚   β”œβ”€β”€ script_rewriter.py  #   Narration style rewriter
β”‚   β”œβ”€β”€ capcut_director.py  #   CapCut export
β”‚   └── panel_filter.py     #   Panel quality filtering
β”‚
β”œβ”€β”€ models/                 # YOLO model weights (committed)
β”‚   β”œβ”€β”€ manhwa_panel_cropped.pt      # Art panel detector
β”‚   └── panel_with_bubble_text.pt    # Bubble panel detector
β”‚
β”œβ”€β”€ templates/              # HTML templates
β”œβ”€β”€ static/                 # CSS, JS, logos
β”œβ”€β”€ assets/                 # BGM, watermarks, intros, outros
└── tests/                  # Test & diagnostic scripts

Generated Folders (gitignored)

Folder Contents
manhwa_download/ Downloaded chapter images + per-chapter state
manhwa_stitch/ Stitched full-page strips
manhwa_detect/ Detection metadata (bounding boxes)
manhwa_crop/ Cropped individual panels
manhwa_text/ Extracted dialogue JSON
manhwa_audio/ Generated TTS audio files
manhwa_clips/ Final rendered video clips
output/ Legacy output directory
~/RECAP/Cast Data/ Your character casts (faces + profiles)

All generated data is regenerable β€” delete any folder and re-run the pipeline.


βš™οΈ Configuration

API Keys (Optional)

Copy .env.example to .env and fill in keys only for services you want to use:

cp .env.example .env
Key Service Required?
GEMINI_API_KEY Google Gemini narration Only if using Gemini
ANTHROPIC_API_KEY Claude narration Only if using Claude
ELEVENLABS_API_KEY ElevenLabs TTS Only if using ElevenLabs
MAL_CLIENT_ID MyAnimeList import Only if importing characters from MAL
NINE_ROUTER_API_KEY 9router narration backend Only if your 9router instance requires one

Ollama + Edge TTS work completely offline β€” no API keys needed for the core pipeline.

Ollama Models

Model Role Size Required?
qwen2.5vl:3b Vision parser (reads panels) ~2 GB βœ… Required
qwen2.5:14b Text-only narrator ~9 GB πŸ“Œ Recommended
qwen2.5vl:7b Vision narrator (sees panels + cast) ~5 GB Optional

Override any of these with the VISION_MODEL, WRITER_MODEL and TEXT_WRITER_MODEL environment variables. With 9router you will want to β€” it addresses models by its own tier names (e.g. Free-Tier) rather than Ollama tags, and the health check only reports the model as available when the name matches one 9router returns.


πŸ”§ Troubleshooting

Problem Solution
"Address already in use" Another instance is running: lsof -ti :8080 | xargs kill -9
Ollama dot is red Start Ollama and pull models: ollama pull qwen2.5vl:3b
Downloads hang Protected site β€” the app auto-switches to headless browser (~40s). MangaDex URLs are most reliable.
Bubbles not removed EasyOCR inpainter handles clear bubbles; complex ones can be fixed with the crop tool in Review.
ModuleNotFoundError Make sure your venv is activated: source venv/bin/activate
Torch install fails Try: pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu

πŸ™ Acknowledgments & Credits

AniFlow is built on the shoulders of many incredible open-source projects. Huge thanks to:

AI & Machine Learning

  • Ollama β€” Local LLM runtime for AI narration and text extraction
  • Qwen 2.5 VL by Alibaba Cloud β€” Vision-language model for panel understanding
  • Ultralytics YOLOv8 β€” Object detection framework for panel detection
  • Magi v2 by Ragav Sachdeva β€” Manga/comic page understanding and speaker-aware transcription
  • EasyOCR by JaidedAI β€” Text detection for speech bubble cleaning
  • Manga OCR by kha-white β€” OCR tuned for manga/manhwa text
  • Google Gemini API β€” Cloud AI narration alternative
  • Anthropic Claude API β€” Cloud AI narration alternative

Text-to-Speech

  • Edge TTS by rany2 β€” Free Microsoft Edge TTS (default engine)
  • Kokoro TTS by hexgrad β€” High-quality local text-to-speech
  • ElevenLabs β€” Premium cloud TTS

Video & Image Processing

  • MoviePy by Zulko β€” Python video editing
  • FFmpeg β€” The backbone of all media processing
  • OpenCV β€” Computer vision operations
  • Pillow β€” Image manipulation

Web Scraping

  • Beautiful Soup by Leonard Richardson β€” HTML parsing
  • curl_cffi β€” Cloudflare-friendly HTTP with TLS fingerprinting
  • CloudScraper by VeNoMouS β€” Cloudflare challenge bypass
  • DrissionPage by g1879 β€” Headless browser fallback for protected sites

Web Framework

Other


πŸ“œ License

This project is licensed under the MIT License.


🀝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.


Made with ❀️ for the manhwa community

About

🎬 Autonomous AI Studio for Manhwa & Webtoon Recaps β€” Vision Pipeline (YOLOv8 + Magi v2), Multi-Voice TTS & Video Synthesis

Topics

Resources

Contributing

Security policy

Stars

54 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages