Skip to content

CyberAgentAILab/LayerD

Repository files navigation

LayerD: Decomposing Raster Graphic Designs into Layers

Tomoyuki Suzuki1Kang-Jun Liu2Naoto Inoue1Kota Yamaguchi1

1CyberAgent, 2Tohoku University

ICCV 2025

arxiv paper

LayerD layer decomposition example

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.

Installation

Install LayerD with pip:

pip install git+https://github.com/CyberAgentAILab/LayerD.git

For other installation options (dataset generation, training, development), see the Installation Guide.

Quick Start

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).

Features

  • 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)

Which API Should I Use?

High-Level Pipeline API (Recommended for Most Users)

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.

Low-Level Decomposition API

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.

Export Formats

SVG (Scalable Vector Graphics)

Best for:

  • Web applications and responsive design
  • Self-contained files (base64 embedding)
  • Easy inspection and editing in code
  • Metadata preservation

PSD (Photoshop Document)

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.

Advanced Usage

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.

Using Custom Weights

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")

Documentation

License

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.

Citation

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}
}