Tomoyuki Suzuki1
Kang-Jun Liu2
Naoto Inoue1
Kota Yamaguchi1
1CyberAgent, 2Tohoku University
LayerD is a layer decomposition method that extracts editable layers from raster graphic design images. This repository contains the official implementation of our ICCV 2025 paper.
See our project page for more details.
Install LayerD with pip:
pip install git+https://github.com/CyberAgentAILab/LayerD.gitFor other installation options (dataset generation, training, development), see the Installation Guide.
Decompose an image into layers and export to SVG:
from layerd import LayerDPipeline
from PIL import Image
pipeline = LayerDPipeline(device="cpu")
image = Image.open("./data/test_image_2.png")
result = pipeline(image)
result.save("output.svg")The pipeline handles decomposition, organization, and export in one call. Results include organized elements with type classification (text/vector/image).
- Layer Decomposition - BiRefNet-based matting extracts clean layers from raster designs
- SVG Export - Generate scalable vector graphics with embedded or external images
- PSD Export - Create Photoshop documents with editable layers
- Element Classification - Automatic detection of text, vector, and image elements
- Unified Pipeline API - Complete workflow from image to export in 3 lines of code
- Custom Weights - Load fine-tuned models from local or remote storage
- OCR Support - Text detection and recognition (coming soon)
Use LayerDPipeline when you want:
- Complete end-to-end workflow (decompose → organize → export)
- SVG or PSD output with structured elements
- Optional OCR integration for text detection
- Element classification (text/vector/image)
See the Pipeline Guide for details.
Use LayerD when you need:
- Direct access to raw RGBA layer images
- Custom post-processing logic
- Integration with your own export workflow
- Maximum control over the decomposition process
See the Inference Guide for details.
Best for:
- Web applications and responsive design
- Self-contained files (base64 embedding)
- Easy inspection and editing in code
- Metadata preservation
Best for:
- Professional design workflows
- Direct Photoshop editing
- Multi-bit depth support (8/16/32-bit)
- Industry-standard format
See the Export Guide for detailed format comparison.
For fine-grained control, use the low-level API:
from layerd import LayerD
layerd = LayerD(matting_hf_card="cyberagent/layerd-birefnet").to("cpu")
layers = layerd.decompose(image)
# ... custom postprocessing ...See the Inference Guide for low-level API details.
LayerD supports loading custom-trained BiRefNet weights from local paths or remote URLs:
from layerd import LayerD
# Local weights
layerd = LayerD(matting_weight_path="./my_birefnet.pth")
# Remote weights (requires appropriate fsspec backend, e.g., gcsfs for gs://)
layerd = LayerD(matting_weight_path="gs://my-bucket/models/birefnet.pth")- Pipeline Guide - High-level API usage and configuration
- Export Guide - SVG and PSD export documentation
- Installation Guide - Detailed setup instructions
- Inference Guide - Low-level API (CLI and Python)
- Training Guide - Training and fine-tuning models
- Evaluation Guide - Evaluating layer decomposition quality
- Architecture - Code architecture and design patterns
- Development Guide - Contributing and development workflows
- Troubleshooting - Common issues and solutions
- Contributing - How to contribute to LayerD
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.
LayerD uses several third-party libraries. See docs/architecture.md for details on bundled dependencies.
If you find this project useful in your work, please cite our paper.
@inproceedings{suzuki2025layerd,
title={LayerD: Decomposing Raster Graphic Designs into Layers},
author={Suzuki, Tomoyuki and Liu, Kang-Jun and Inoue, Naoto and Yamaguchi, Kota},
booktitle={ICCV},
year={2025}
}