Cobra: An Open-Source AI Coloring Model for Line Art, Especially for Manga Coloring
What is Cobra?
Cobra is a novel, efficient long-context fine-grained ID-preserving framework for line art colorization, particularly suited for manga coloring. Cobra converts black-and-white line art into colored illustrations by integrating a broad set of contextual reference images. This approach supports more than 200 reference images while maintaining low latency and offering flexible user control.

Cobra Method
Core Architecture: Cobra is built upon the Causal Sparse DiT architecture, leveraging specially designed positional encodings, causal sparse attention, and key-value caching (KV-Cache) to effectively manage long-context references and ensure color ID consistency.
Locally Reusable Positional Encodings: Ensure appropriate aspect ratios and resolutions.
Causal Sparse Attention: Reduces computational complexity by cutting down pairwise computations between reference images, while incorporating KV-Cache to improve computational efficiency.
Cobra Experimental Results
Qualitative Results: Cobra accurately preserves color IDs in complex scenes and delivers high-quality colorization results.
Quantitative Comparison: Compared with existing manga colorization methods (using metrics such as CLIP-IS, FID, PSNR, SSIM, and AS), Cobra performs excellently on both plain line art and shaded line art colorization.
Impact of Reference Image Quantity: Cobra's performance continues to improve as the number of reference images increases.
Inference Time Efficiency: Causal sparse attention (combined with KV-Cache) demonstrates superior efficiency across different quantities of reference images.

Cobra Application Scenarios
Interactive Line Art Colorization: Users can flexibly control colorization results through color prompts.
Line Art Colorization: Suitable for simple line art.
Shaded Line Art Colorization: Maintains color fidelity and detail in complex scenes.
Line Art Video Colorization: Supports colorization of dynamic content.
Cobra Frequently Asked Questions
Q: What are the main advantages of Cobra compared with other line art colorization methods?
A:Cobra's advantages are reflected in both qualitative and quantitative aspects. Qualitatively, it can accurately preserve color IDs in complex scenes, maintain color fidelity, and enhance detail when processing shaded line art. Quantitatively, it performs better on metrics such as CLIP-IS, FID, PSNR, SSIM, and AS, and offers higher inference time efficiency.
Q: How does the causal sparse DiT architecture in Cobra improve computational efficiency?
A:The causal sparse DiT architecture improves computational efficiency by reducing pairwise computations between reference images, applying unidirectional causal attention, and using KV cache. Reducing pairwise computations lowers computational complexity, while unidirectional causal attention and KV cache ensure the effective transfer of key color ID information during efficient computation.
Q: How does the number of reference images affect Cobra's performance?
A:As the number of reference images increases, Cobra's performance shows a continuous upward trend. For example, the CLIP-IS metric improves from 0.9083 with 4 reference images to 0.9183 with 36 reference images, the FID metric decreases from 23.18 to 20.64, and metrics such as PSNR, SSIM, and AS also show corresponding improvements.
Related Links
Project Page:https://zhuang2002.github.io/Cobra/
Github:https://github.com/Zhuang2002/Cobra
Paper:https://arxiv.org/abs/2504.12240
Script Planner Assistant▸
AI Apps
AI News 