Abstract
SlideCoder is a novel framework designed to transform static images of presentation slides into fully editable PowerPoint files by generating precise Python code. By combining a recursive visual segmentation algorithm with a hierarchical retrieval-augmented generation (RAG) system, it significantly outperforms models like GPT-4o in maintaining layout fidelity and ensuring the generated code actually runs.
Introduction: The Challenge of Visual Slide Generation
Creating professional slides is a time-consuming chore that often requires a "design eye" many users lack. While AI tools that generate slides from text descriptions have proliferated, they often fail when a user provides a visual reference—such as a screenshot of a specific design they wish to replicate.
Current Multimodal Large Language Models (MLLMs) struggle with three primary issues in this domain:
- Visual Imprecision: Natural language is often too vague to describe exact coordinates, colors, and font styles.
- Complexity Overload: In slides packed with elements, models frequently omit items or fail at spatial alignment, leading to "disorder."
- API Hallucination: Models often generate syntactically incorrect code due to a lack of deep, structured understanding of libraries like
python-pptx.
Methodology: The SlideCoder Pipeline
SlideCoder addresses these challenges by breaking the generation process into a structured, multi-stage pipeline.
CGSeg: Color Gradient-based Segmentation
Instead of processing a slide as a single monolithic image, the CGSeg algorithm recursively divides it into "semantic blocks" based on color gradients. This "divide and conquer" approach allows the model to focus on discrete sections of the design, ensuring high-fidelity reconstruction of complex layouts.
H-RAG: Hierarchical Retrieval-Augmented Generation
To eliminate code errors, SlideCoder employs a two-tier knowledge base (H-RAG). A Shape Type KB assists the model in identifying objects (e.g., distinguishing a "connector" from an "autoshape"), while an Operation Function KB provides the exact Python syntax required to instantiate those objects. This serves as a "syntax anchor," preventing the hallucination of non-existent API functions.
Multi-Agent Coordination
The task is distributed across three specialized agents:
- Describer: Details the visual elements within each block.
- Coder: Generates Python snippets for those specific blocks.
- Assembler: Uses a "Layout-aware Prompt" to integrate snippets into a final, executable script, ensuring correct scaling and positioning.
Additionally, the researchers fine-tuned SlideMaster, a 7B parameter model based on Qwen-VL, using a high-quality dataset derived from reverse-engineered PPTX files.
Datasets and Benchmarking
The study introduces Slide2Code, the first benchmark specifically for the "Image-to-Slide" task. It includes 300 samples categorized into Simple, Medium, and Complex tiers using a new Slide Complexity Metric (SCM). Evaluation also utilized the Zenodo10k and SLIDEBENCH datasets.
Key Results and Insights
SlideCoder establishes a new state-of-the-art (SOTA) performance:
- Execution Accuracy: On the Slide2Code benchmark, SlideCoder achieved a 100% execution rate for simple and medium slides, and 96% for complex ones. In comparison, GPT-4o's performance dropped to 69% on complex tasks.
- Layout Fidelity: SlideCoder outperformed top baselines by up to 40.5 points on complex slides, demonstrating significant gains in visual consistency.
- Model Efficiency: The fine-tuned 7B SlideMaster model rivaled the performance of the much larger GPT-4o, highlighting the value of specialized training data over raw parameter count.
Limitations and Future Directions
Despite its success, the framework has limitations. It currently generates slides individually, lacking the cohesive "flow" required for multi-slide decks. Furthermore, the rule-based CGSeg algorithm may struggle with "flattened" images where text is integrated into complex backgrounds. Future work will explore more flexible, model-based detection systems to enhance block partitioning.
Summary updated