Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raster-to-Vector: Neural Logo Vectorization for Engraving

A systematic ML research investigation exploring whether neural networks can convert raster logo images into production-ready vector (EPS) files for laser/diamond-drag engraving.

The Problem

In the engraving industry, customers send logos as raster images — photos, screenshots, low-res JPEGs, scanned business cards. A human operator manually traces these into vector paths using Adobe Illustrator. This is skilled, time-consuming labor: 22,000+ logos converted to date, supporting 500K-1M engraving operations annually.

The question: Can a neural network learn to do this?

This is not a generic image-to-SVG task. The output must be:

  • Engraving-ready: outlined compound paths, zero fills, binary cut paths
  • Manufacturing-constrained: correct path topology for tool-path generation
  • Production-quality: clean beziers, proper winding, welded overlaps

What This Repo Contains

Six neural architectures were tested, plus a ground truth extraction pipeline and a Stage 1 region detection model. Each attempt is preserved in attempts/ with its full source code.

attempts/

Attempt Architecture Key Idea Outcome
A — StarVector Baseline ResNet-50 encoder + MoE decoder Tokenize EPS commands + coordinates, autoregressive generation 99% command accuracy, 5.96% coordinate accuracy. Encoder collapses spatial resolution.
B — ViT + Residual Quantization ViT encoder + RQ coordinate decoder Multi-level coordinate quantization to break down the coordinate space Better than A but still struggles with complex curves and coordinate collapse
C — Dragon Hatchling SSM BDH state-space model Replace transformer with SSM for linear-time sequence generation 37% ceiling. Causal-only masking wrong for this task. Implementation wasn't the paper's architecture.
D — HiFi Autoreg Vector DINOv2 encoder + dual decoder + MDN + heatmap Mixture Density Network for coordinate distribution + CNN heatmap for spatial Most advanced. 23+ experiments. MDN collapse: all 25 Gaussian components converge to identical sigma. Coordinate accuracy plateaus at 1-13%.
E — StarVector v1-v4 (early) Upstream StarVector models Fine-tune pre-trained image-to-SVG models Tested v1 through v4. Did not produce engraving-ready output.
F — StarVector-1B QLoRA StarVector 1B + QLoRA fine-tune Fine-tune 1B parameter model on engraving dataset with quantized LoRA Full training pipeline with caching, validation, Gravostyle loss. Closest to production but model output still not engraving-ready.

stage1_detection/

Ground truth extraction pipeline and Stage 1 region detection model. This is the data engineering that made everything else possible:

  • extract_structured_vectors.py (841 lines) — Extracts working vector paths from multi-layer Adobe Illustrator files, producing the intermediate representation that enables hierarchical training
  • ground_truth_pipeline.py (559 lines) — Produces detection labels from structured vectors for Stage 1 training
  • train_stage1.py (304 lines) — Trains ResNet-50 + FPN detector for single-class "element" region detection
  • evaluate_stage1.py (447 lines) — Validation with IoU metrics and visualizations
  • Plus data analysis scripts: path alignment, fill/outline pattern measurement, overlap analysis

setup/

DGX Spark setup scripts — hardware configuration, software installation, data transfer, environment validation.

docs/

Research documentation covering the full investigation:

  • Pipeline architecture — the crop-first + hierarchical two-stage design
  • Key problems & failures — systematic failure analysis across all attempts
  • Ground truth pipeline — how 22K logos were processed into training data
  • Per-attempt writeups — what was tried, what happened, what was learned

Key Findings

The Core Bottleneck: Coordinate Prediction

All six architectures achieved high command accuracy (99%+) but failed at coordinate accuracy (1-13%). The model learns "what commands to issue" but not "where to draw."

Two distinct failure modes were identified and characterized:

  1. Stuck-in-place oscillation — Model predicts near-identical coordinates, producing a dense cluster of paths at one spot while the rest of the canvas is blank
  2. Degenerate path syntax — Model generates zero-area paths (moveto → closepath with no geometry) as a loss-minimizing strategy

What Was Exhaustively Eliminated

23+ experiments on the HiFi architecture alone systematically ruled out:

  • Loss function tricks (weight schemes, focal loss, entropy regularization)
  • Gradient interference fixes (backbone freeze, gradient valves, separate heads)
  • Coordinate encodings (absolute, delta, curriculum, continuous regression)
  • MDN mode (25 components all collapsed to identical sigma)
  • White space penalty (changed command distribution but didn't fix coverage)

The Insight That Emerged

The bottleneck is not in the model architecture or loss function — it's in the data representation. The operator is interpreting degraded source images, not transcribing them. The model needs to learn interpretation, not just coordinate mapping. This led to the crop-first + hierarchical pipeline design that uses intermediate supervision (raster → working vectors → final EPS) instead of end-to-end generation.

Technical Stack

  • Hardware: NVIDIA DGX Spark (Grace + Blackwell, 128GB unified memory)
  • Framework: PyTorch 2.9+, CUDA 13, TransformerEngine (NVFP4 quantization)
  • Models: ResNet-50, ViT, DINOv2, custom BDH SSM, StarVector 1B
  • Training: Mixed precision (BF16/FP4), gradient accumulation, LR range testing
  • Data: 22,000+ logos with working vector ground truth extracted from Illustrator files
  • Inference: EPS generation with raster rendering feedback loop (RLRF)

Repository Structure

raster-to-vector/
├── attempts/
│   ├── a_starvector_baseline/     # ResNet + MoE (19 .py + scripts + docs)
│   ├── b_vit_residual_quant/       # ViT + RQ (shares A's codebase, different config)
│   ├── c_dragon_ssm/               # BDH state-space model (bdh_core/)
│   ├── d_hifi_mdn_heatmap/         # DINOv2 + MDN + heatmap (24 .py + 59 scripts)
│   └── f_starvector_1b_qlora/      # StarVector 1B QLoRA (14 .py + configs + docs)
├── stage1_detection/               # Ground truth pipeline + region detection (21 .py)
├── setup/                          # DGX Spark setup scripts
└── docs/                           # Research documentation and experiment writeups

Context

This project was built by Thad Reber, who runs a raster-to-vector conversion business serving the world's largest Cutco engraver. Over 15+ years, he has personally converted 22,000+ raster logos into production-ready vector files — real client artwork that feeds real engraving operations.

He bought an NVIDIA DGX Spark and set out to determine whether a neural network could automate the conversion work he's been doing by hand for over a decade.

No ML background. No CS degree. No research lab. One person with deep domain expertise, a workstation, and the willingness to test six different architectures and run 23+ experiments before reaching a conclusion.

The dataset is real production data: actual client logos with ground truth vectors extracted from the working Illustrator files used in production.

About

Systematic ML research investigation: six neural architectures for converting raster logo images to production-ready vector (EPS) files for engraving. 55K lines of Python, 23+ experiments, documented failure analysis.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages