๐ The beginning of bringing comics to life through AI-powered animation
ComicFrames is a foundational Python package for comic book analysis and the first step toward creating animated storytelling experiences. Starting with robust frame detection using OpenCV and computer vision, this project is evolving into a complete animation pipeline powered by state-of-the-art neural networks like RIFE, FILM, and YOLO.
This project represents the starting point of a larger vision: transforming static comic books into dynamic, animated experiences. We're building the infrastructure and tools that will eventually power:
- ๐ฌ Seamless frame interpolation for smooth panel transitions
- ๐ญ Character animation within comic panels
- ๐ฌ Speech bubble dynamics and text-to-speech integration
- ๐จ Style-aware animation preserving artistic integrity
- ๐ฎ Interactive comic experiences with user-driven pacing
- ๐ PDF Processing: High-quality comic book to image conversion with PyMuPDF
- ๐ OpenCV Frame Detection: Two robust methods (threshold & Canny edge detection)
- ๐๏ธ Modular Architecture: Clean separation with processing pipelines and caching
- ๐ฅ๏ธ CLI Tools: 5 command-line utilities for batch processing
- โก Smart Caching: Multi-level cache system with TTL and performance metrics
- ๐ก๏ธ Type Safety: Complete type annotations and runtime validation
- ๐ฌ RIFE Integration: Real-time frame interpolation (models included, implementation ongoing)
- ๐ญ FILM Integration: Google's large motion interpolation (setup complete, API in progress)
- ๐ YOLO Detection: Speech bubble and character detection (config ready, training needed)
- ๐ค Hugging Face Pipeline: Model hub integration for community models
- ๐จ Animation Export: MP4/GIF generation from interpolated frames
- ๐ฌ Text Analysis: OCR and speech bubble text extraction
- ๐ฎ Interactive Viewer: Web-based comic animation player
- ๐ญ Character Tracking: Persistent character identification across panels
ComicFrames currently uses proven computer vision techniques for robust frame detection:
# Threshold-based detection (clean, geometric panels)
_, binary = cv2.threshold(gray, 225, 255, cv2.THRESH_BINARY_INV)
contours, hierarchy = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# Canny edge detection (complex, artistic layouts)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edges = cv2.Canny(blurred, 10, 200)
contours = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)The architecture is designed for easy model swapping once neural implementations are complete:
- ๐ฌ RIFE v4.6: 130+ FPS frame interpolation (PyTorch models downloaded)
- ๐ญ FILM: TensorFlow-based large motion interpolation (Google Research)
- ๐ YOLOv3: Real-time object detection (config files ready)
- ๐ค Hugging Face: Community model integration via ModelFactory
- ๐ง Plugin System: Easy model registration and switching
- โก Caching: Intelligent model loading and result caching
- ๐ Metrics: Performance monitoring for all processing stages
- ๐๏ธ Pipelines: Chain OpenCV โ Neural Network โ Animation export
from comicframes import pdf_to_images, detect_frames
# Convert comic PDF to high-quality page images
pdf_to_images("watchmen.pdf", output_dir="./pages")
# Extract individual panels using OpenCV
frames_detected = detect_frames("./pages/page_1.png", method="threshold")from comicframes import ModelFactory, ProcessingPipeline
# Create interpolation pipeline (implementation ongoing)
rife_model = ModelFactory.create_model("rife_v4.6")
film_model = ModelFactory.create_model("film_net")
# Chain frame detection โ interpolation โ animation
pipeline = ProcessingPipeline("comic_animation")
pipeline.add_stage(PDFProcessor())
pipeline.add_stage(FrameProcessor())
pipeline.add_stage(InterpolationProcessor(rife_model))
result = pipeline.process("comic.pdf")# Future API for complete animation generation
animator = ComicAnimator()
animator.load_comic("comic.pdf")
animator.set_transition_style("smooth") # smooth, cinematic, dynamic
animator.add_speech_timing("auto") # auto, manual, voice-sync
animated_comic = animator.render(output_format="mp4")-
RIFE (ECCV 2022): Real-Time Intermediate Flow Estimation
- โก 130+ FPS on RTX 3090
- ๐ฏ State-of-the-art interpolation quality
- โ
Models Downloaded (
external_models/ECCV2022-RIFE/)
-
FILM (Google Research): Frame Interpolation for Large Motion
- ๐ญ Large motion handling for dramatic panel transitions
- ๐ง TensorFlow implementation with pre-trained models
- โ
Repository Integrated (
external_models/frame-interpolation/)
- YOLOv3: Real-time object detection
- ๐ฌ Speech bubble detection and text region identification
- ๐ฅ Character detection for tracking across panels
- โ
Config Ready (
external_models/Yolo_Model/)
# Future community model integration
from comicframes import ModelFactory
# Load community-trained comic-specific models
speech_detector = ModelFactory.create_model("huggingface/comic-speech-detection")
character_classifier = ModelFactory.create_model("huggingface/comic-character-recognition")
style_interpolator = ModelFactory.create_model("huggingface/comic-style-preserving-interpolation")๐ฆ PyPI Status: Package not yet published to PyPI. Install from source for now.
# Clone the repository
git clone https://github.com/pr1m8/comicframes.git
cd comicframes
# Install with uv (recommended)
uv pip install -e .
# Or install with pip
pip install -e .# Core dependencies (automatically installed)
pymupdf>=1.23.0 # PDF processing
opencv-python>=4.5.0 # Computer vision
numpy>=1.21.0 # Numerical operations
pillow>=8.0.0 # Image manipulation# Coming soon - when package is published
uv pip install comicframes
pip install comicframesfrom comicframes import pdf_to_images, detect_frames
# Extract pages from comic PDF
pdf_to_images("watchmen.pdf", output_base_dir="./pages")
# Detect panels using OpenCV computer vision
total_frames = detect_frames("./pages/page_1.png",
min_width=100,
detection_method="threshold")
print(f"Detected {total_frames} panels ready for animation")from comicframes.processing import PDFProcessor, FrameProcessor
from comicframes.core import ProcessingPipeline
# Create a complete comic processing pipeline
pipeline = ProcessingPipeline("comic_analysis")
pipeline.add_stage(PDFProcessor()) # PDF โ Images
pipeline.add_stage(FrameProcessor()) # Images โ Panel detection
# Process entire comic book
result = pipeline.process("comic.pdf")
print(f"Pipeline processed {len(result.data)} pages")from comicframes import Settings, get_cache_manager
# Configure for optimal performance
settings = Settings(
min_frame_width=75, # Adjust for comic style
min_frame_height=100, # Filter out small panels
enable_cache=True # Cache processing results
)
# Monitor processing performance
cache = get_cache_manager()
stats = cache.get_cache_stats()
print(f"Cache hit ratio: {stats.hit_ratio:.2%}")# Future API - Neural network enhanced processing
from comicframes import ModelFactory
from comicframes.models import RIFEInterpolator, FILMInterpolator
# Load state-of-the-art interpolation models
rife = ModelFactory.create_model("rife_v4.6") # 130+ FPS interpolation
film = ModelFactory.create_model("film_net") # Large motion handling
# Create smooth panel transitions
interpolated_frames = rife.interpolate_between_panels(
panel_1="frame_001.png",
panel_2="frame_002.png",
transition_frames=8, # 8 intermediate frames
preserve_style=True # Maintain comic art style
)# Basic usage
comicframes-pdf comic.pdf
# Specify output directory
comicframes-pdf comic.pdf --output-dir ./my_output
# Skip automatic frame detection
comicframes-pdf comic.pdf --no-frame-detection# Basic usage
comicframes-extract ./pages ./output
# With custom minimum frame sizes
comicframes-extract ./pages ./output --min-width 100 --min-height 150# Complete processing pipeline
comicframes-pipeline comic.pdf --output-dir ./output --model opencv_contours
# Cache management
comicframes-cache stats
comicframes-cache clear --type processing
comicframes-cache cleanup
# Model management
comicframes-models list
comicframes-models info opencv_contourscomicframes/ # Clean, organized root
โโโ src/comicframes/ # Main package source
โ โโโ config/ # Configuration management
โ โโโ cache/ # Caching system
โ โโโ core/ # Core abstractions
โ โโโ models/ # Model implementations
โ โโโ processing/ # High-level processors
โ โโโ pdf_processor.py # Legacy compatibility
โ โโโ frame_detector.py # Legacy compatibility
โ โโโ cli.py # Command-line interface
โโโ external_models/ # External model integrations
โ โโโ ECCV2022-RIFE/ # RIFE frame interpolation
โ โโโ frame-interpolation/ # Google FILM models
โ โโโ Yolo_Model/ # YOLO object detection
โโโ data_samples/ # Sample data and tests
โ โโโ Data/ # Sample comic data
โ โโโ test_data/ # Test files
โโโ examples/ # Usage examples
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โโโ scripts/ # Utility scripts
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/
isort src/
# Lint code
flake8 src/# Build wheel and source distribution
python -m build
# Install locally
uv pip install dist/comicframes-*.whlStatus: Production Ready - Solid computer vision foundation
- โ PDF Processing: PyMuPDF integration for high-quality page extraction
- โ OpenCV Frame Detection: Threshold & Canny edge detection algorithms
- โ Processing Architecture: Modular pipeline system with caching
- โ CLI Tools: 5 command-line utilities for batch processing
- โ Developer Experience: Type safety, documentation, testing framework
Status: In Progress - Models downloaded, API implementation ongoing
- ๐ RIFE Implementation: Complete PyTorch model integration (models ready)
- ๐ FILM Implementation: TensorFlow model wrapper development
- ๐ YOLO Integration: Object detection for speech bubbles and characters
- ๐ Model Management: Enhanced ModelFactory with automatic downloading
- ๐ Performance Optimization: GPU acceleration and batching support
Status: Planned - Animation pipeline and export capabilities
- ๐ฏ Frame Interpolation: Smooth transitions between comic panels
- ๐ฏ Animation Export: MP4/GIF generation with customizable timing
- ๐ฏ Transition Effects: Multiple animation styles (smooth, cinematic, dynamic)
- ๐ฏ Batch Animation: Process entire comic books into animated sequences
- ๐ฏ Quality Controls: Resolution, frame rate, and compression options
Status: Future - Advanced features and user interfaces
- ๐ฎ Web Interface: Browser-based comic animation viewer
- ๐ฎ Speech Integration: Text-to-speech with character voice synthesis
- ๐ฎ Character Tracking: Persistent character identification across panels
- ๐ฎ Style Transfer: Artistic style preservation during animation
- ๐ฎ Interactive Timing: User-controlled pacing and panel transitions
Status: Visionary - Advanced AI for narrative understanding
- ๐ฎ Story Analysis: Automated narrative flow detection
- ๐ฎ Emotion Detection: Character emotional state recognition
- ๐ฎ Scene Understanding: Context-aware animation decisions
- ๐ฎ Multi-language: Global text extraction and voice synthesis
- ๐ฎ Community Models: Hugging Face Hub integration for specialized models
computer-vision comic-analysis frame-detection animation ai machine-learning opencv yolo rife film huggingface python cli processing-pipeline caching
We welcome contributions! ComicFrames is designed to be easily extensible:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Add your processor/model: Follow our plugin architecture
- Add tests: Ensure your code is well-tested
- Submit a PR: We'll review and merge
See our Contributing Guide for detailed instructions.
If you use ComicFrames in your research, please cite:
@software{comicframes2024,
title={ComicFrames: AI-Powered Comic Book Analysis and Animation},
author={ComicFrames Project},
year={2024},
url={https://github.com/pr1m8/comicframes},
version={0.1.0},
note={Foundation for neural network-based comic animation}
}- ECCV2022-RIFE - Real-Time Intermediate Flow Estimation
- frame-interpolation - Google's FILM models
- YOLOv8 - Object detection framework
- Hugging Face Hub - Model repository and hosting
MIT License - see the LICENSE file for details.