A newer version of the Gradio SDK is available: 6.25.0
metadata
title: PNG JPG to SVG
emoji: ✒️
colorFrom: gray
colorTo: indigo
sdk: gradio
sdk_version: 6.5.1
app_file: app.py
pinned: false
license: mit
suggested_hardware: cpu-basic
short_description: Vectorize bitmaps into clean SVG paths
PNG / JPG to SVG
Turns raster images into scalable SVG paths, tuned for clean line work on AI-generated drawings, logos and sketches. CPU only — no GPU needed.
Set
sdk_versionabove to the value Hugging Face put in the README it generated when you created the Space.
Setup
- New Space → SDK Gradio → hardware CPU basic (ZeroGPU will refuse to
start, since this app has no
@spaces.GPUfunction). - Upload
app.py,requirements.txtandREADME.mdto the repository root. - Wait for the build. First run takes 2–3 minutes.
Locally:
pip install -r requirements.txt
python app.py
Pipeline
| Stage | What happens |
|---|---|
| Prepare | Composite alpha onto white, fix EXIF rotation, optional 2–4× upscale |
| Isolate | Autocontrast, median smoothing, threshold (Otsu, global or adaptive) |
| Centerline | Zhang-Suen skeletonization, then dilation to one constant stroke width |
| Trace | VTracer emits Bézier splines or polygons |
| Clean up | Strip white background fills, recolor lines, set viewBox to source size |
Controls that actually matter
- Upscale before tracing — the single biggest lever for smooth curves. Start at 2×, go to 3× for small sources.
- Uniform stroke width — pulls each line onto its centerline and redraws it at constant weight. Fixes the ragged edges typical of generated images and cuts file size by roughly half.
- Filter small specks — removes JPEG compression artifacts. Set to 8–12 for JPG sources.
- Corner threshold — high for soft organic lines, low for technical drawings with crisp corners.
- Adaptive threshold — for photos of paper sketches with uneven lighting.
Limits
Photographs with gradients produce many paths and large files in color mode — lower the color depth and raise speck filtering. Fine halftone dots and screen patterns don't translate into meaningful lines.
Images larger than 2600 px on the long edge are downscaled before tracing so the Space doesn't time out.