Skip to content

Repository files navigation

SlideCraft: Synthetic Slides Generation for Robust Slide Analysis

Paper HAL

Official implementation of the paper:

SlideCraft: Synthetic Slides Generation for Robust Slide Analysis Travis Seng, Axel Carlier, Thomas Forgione, Vincent Charvillat, Wei Tsang Ooi International Conference on Document Analysis and Recognition (ICDAR), 2024

SlideCraft is a tool for creating synthetic slide datasets that imitate real-world presentations. It parses Wikipedia articles, generates diverse presentation slides using Marp, and extracts bounding box annotations in YOLO format for training slide layout analysis and object detection models.

Architecture

The pipeline consists of five stages:

Wikipedia Parsing  -->  Content Summarization  -->  Slide Generation  -->  Rendering  -->  Annotation Extraction
(parse_wikipedia)      (summarize + parse_sum)     (generate_slides)     (render /       (slides_to_bbox /
                                                                          slides_to_img)   get_annotations)
  1. Wikipedia Parsing - Fetches and structures Wikipedia articles into JSON (sections, images, equations, tables)
  2. Content Summarization (optional) - Uses a local LLM (Mistral) to create concise slide content
  3. Slide Generation - Generates diverse Marp markdown slides with randomized layouts, themes, fonts, backgrounds, headers, and footers
  4. Rendering - Converts markdown to PDF/HTML via Marp CLI, then extracts PNG images
  5. Annotation Extraction - Extracts image/text bounding boxes from PDFs in YOLO format

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • GNU Parallel (for batch rendering)

Installation

git clone https://github.com/YOUR_USERNAME/slidecraft.git
cd slidecraft

# Python dependencies
pip install -r requirements.txt

# Node.js dependencies (Marp CLI)
npm install

# Locator tool (HTML element bounding box extractor)
cd tools/locator && npm install && cd ../..

Asset Setup

The following directories must be set up before generating slides. They are not included in the repository due to size.

Directory Contents Required
themes/ Marp CSS theme files Yes
assets/ Images for slide content (see below) Optional
fonts.json List of Google Fonts to use Included
utils/latex_formulas.txt LaTeX formulas for slide diversity (5k sample included) Included

All external assets live under assets/. Every subdirectory is optional — if it's missing or empty, that content type is simply skipped during generation.

assets/
  backgrounds/   Background images for slides
  logos/          Brand/company logos for slide headers
  figures/        Scientific document figures (e.g. DocFigure)
  tables/         Table images (e.g. TableBank)
  charts/         Chart images (e.g. PlotQA)
  diagrams/       Science diagrams (e.g. AI2D)
  handwriting/    Handwritten text/notes
  persons/        Instructor/speaker photos

Marp theme CSS files go in themes/.

Suggested data sources

Directory Source Link
figures/ DocFigure https://doc-figure.github.io/
tables/ TableBank https://doc-analysis.github.io/tablebank-page/
charts/ PlotQA https://github.com/NiteshMethwormo/PlotQA
diagrams/ AI2D (Allen AI) https://allenai.org/data/diagrams

Adjust the weight_* parameters in config.yaml to control which content types are used and how often.

Usage

1. Parse Wikipedia articles

# Parse a single article
python scripts/parse_wikipedia.py --title "Machine Learning"

# Parse an article and all its linked articles (up to 50)
python scripts/parse_wikipedia.py --title "Machine Learning" --related --limit 50

2. Summarize content (optional, requires local LLM)

python scripts/summarize.py --model-path /path/to/mistral-7b-instruct.gguf
python scripts/parse_sum.py

3. Generate slides

# From raw Wikipedia content (no LLM needed)
python scripts/generate_slides.py --input-dir Wikipedia --output-dir output --raw

# From summarized content (requires step 2)
python scripts/generate_slides.py --input-dir Wikipedia --output-dir output

4. Render slides to HTML and images

Use Marp CLI to convert the generated markdown to HTML and PNG:

# Full batch pipeline (Marp + rename + Locator, requires GNU Parallel)
python scripts/render.py --output-dir output

# Or convert PDFs to PNG individually
python scripts/slides_to_img.py --output-dir output

render.py runs three steps: Marp CLI (markdown → HTML + PNG), rename_slide.sh (renames PNGs to article.NNN.png), and Locator (extracts element bounding boxes).

5. Run Locator (element bounding boxes)

The Locator tool (tools/locator/) analyses the rendered HTML slides using Puppeteer and extracts bounding boxes for every HTML element as normalized coordinates (0–1). Output is a JSON file per article.

# Run on all slides via the helper script
python scripts/locator.py

# Run on a single article
node tools/locator/index.js --input output/article_name/slide.html > output/article_name/boxes.json

# With mask generation (slower, saves per-element screenshots)
node tools/locator/index.js --input output/article_name/slide.html -a -t 0 -f -o output/article_name/masks

6. Extract annotations

Convert bounding boxes to YOLO-format labels for training object detection models:

# From PDFs: extract image bounding boxes
python scripts/slides_to_bbox.py --output-dir output

# From PDFs: extract text + image annotations
python scripts/get_annotations.py --output-dir output

# From Locator JSON: convert to YOLO labels
python scripts/parse_locator.py --json output/article_name/boxes.json --labels-dir output/labels

# Visualize Locator boxes on a slide image
python scripts/parse_locator.py --image output/article_name/slide.001.png --json output/article_name/boxes.json

Pretrained Model

A YOLOv8 model (slide-model.pt) trained on a mix of SlideCraft-generated data and SlideVQA is included in the repository. It detects the following 9 classes:

ID Class Description
0 title Slide title
1 page-text Body text, bullet points
2 obj-text Text inside objects (table cells, etc.)
3 caption Image/figure captions
4 other-text Headers, footers, code blocks
5 diagram Diagrams and charts
6 table Tables
7 image Images and figures
8 chart Charts
from ultralytics import YOLO
model = YOLO("slide-model.pt")
results = model("slide.png")

Configuration

Edit config.yaml to control slide generation parameters:

added_content:
  nb_added_content: [0, 0]     # Range of extra content items per slide
  weight_figures: 0             # Probability weight for adding figures
  weight_tables: 0              # Probability weight for adding tables
  weight_logos: 1               # Probability weight for adding logos
  prob_header: 0.1              # Probability of adding a header
  prob_footer: 0.1              # Probability of adding a footer
  font_size: [29, 40]           # Font size range (px)
  prob_display_title: 1         # Probability of showing slide title

background:
  weight_white_bg: 8            # Weight for white backgrounds
  weight_black_bg: 2            # Weight for black backgrounds
  weight_colored_bg: 1          # Weight for random colored backgrounds
  weight_gradient_bg: 1         # Weight for gradient backgrounds
  weight_image_bg: 1            # Weight for image backgrounds

layout:
  nb_max_img_wiki: 6            # Max Wikipedia images per slide
  prob_caption: 0               # Probability of auto-generated captions

Project Structure

slidecraft/
  slidecraft/          Core Python package
    __init__.py          Config loading and BASE_DIR
    controller.py        Slide creation orchestrator
    layout.py            Slide/Page/Header/Footer/Image/Text classes
    content.py           Wikipedia JSON content parser
    utils.py             Markdown conversion utilities
  scripts/             CLI entry points
  tools/locator/       HTML element bounding box extractor (Node.js)
  assets/              External images (backgrounds, logos, figures, ...)
  themes/              Marp CSS themes
  utils/               Shell scripts and static data files
  config.yaml          Generation parameters
  fonts.json           Available Google Fonts

Citation

If you use SlideCraft in your research, please cite:

@inproceedings{seng2024slidecraft,
  title={SlideCraft: Synthetic Slides Generation for Robust Slide Analysis},
  author={Seng, Travis and Carlier, Axel and Forgione, Thomas and Charvillat, Vincent and Ooi, Wei Tsang},
  booktitle={International Conference on Document Analysis and Recognition (ICDAR)},
  pages={79--96},
  year={2024},
  doi={10.1007/978-3-031-70533-5_6}
}

License

This project is licensed under the MIT License - see LICENSE for details.

About

Repository for SlideCraft implementation

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages