Show HN: Txt2plotter – True centerline vectors from Flux.2 for pen plotters
Posted by tsanummy 4 days ago
I’ve been working on a project to bridge the gap between AI generation and my AxiDraw, and I think I finally have a workflow that avoids the usual headaches.
If you’ve tried plotting AI-generated images, you probably know the struggle: generic tracing tools (like Potrace) trace the outline of a line, resulting in double-strokes that ruin the look and take twice as long to plot.
What I tried previously:
- Potrace / Inkscape Trace: Great for filled shapes, but results in "hollow" lines for line art.
- Canny Edge Detection: Often too messy; it picks up noise and creates jittery paths.
- Standard SDXL: Struggled with geometric coherence, often breaking lines or hallucinating perspective.
- A bunch of projects that claimed to be txt2svg but which produced extremely poor results, at least for pen plotting. (Chat2SVG, StarVector, OmniSVG, DeepSVG, SVG-VAE, VectorFusion, DiffSketcher, SVGDreamer, SVGDreamer++, NeuralSVG, SVGFusion, VectorWeaver, SwiftSketch, CLIPasso, CLIPDraw, InternSVG)
My Approach:
I ended up writing a Python tool that combines a few specific technologies to get a true "centerline" vector:
1. Prompt Engineering: An LLM rewrites the prompt to enforce a "Technical Drawing" style optimized for the generator.
2. Generation: I'm using Flux.2-dev (4-bit). It seems significantly better than SDXL at maintaining straight lines and coherent geometry.
3. Skeletonization: This is the key part. Instead of tracing contours, I use Lee’s Method (via scikit-image) to erode the image down to a 1-pixel wide skeleton. This recovers the actual stroke path.
4. Graph Conversion: The pixel skeleton is converted into a graph to identify nodes and edges, pruning out small artifacts/noise.
5. Optimization: Finally, I feed it into vpype to merge segments and sort the paths (TSP) so the plotter isn't jumping around constantly.
You can see the results in the examples inside the Github repo.
The project is currently quite barebones, but it produces better results than other options I've tested so I'm publishing it. I'm interested in implementing better pre/post processing, API-based generation, and identifying shapes for cross-hatching.
Comments
Comment by c-jiph 1 day ago
I didn't actually end up playing with it too much but the problem I found was it's a hard to get a one-size-fits-all prompt. The AI generated images are usually okay but some features aren't great for a plotter or just don't look visually pleasing. It's still better than having to manually mess with the initial image.
Comment by ansc 1 day ago
Comment by mft_ 1 day ago
FLUX.2 can run on a Mac - any thoughts on making this work on Mac? Needing a 24GB NVidia card is limiting…
Comment by hwj 1 day ago
> NVIDIA GPU with 24GB VRAM (RTX 3090/4090)
That's a little bit to much for my trusty notebook...
Comment by thot_experiment 8 hours ago
very depressing that our incentive structures are so malformed that finding the 27 year old solution is more difficult than burning a few kW getting an LLM to regurgitate a facsimile
Comment by piebro 1 day ago
In the end I just used potracer and was fine with having double lines for my cards: https://github.com/piebro/personal-plotting-util/blob/main/i...
Comment by max002 1 day ago
Comment by joshu 1 day ago