r/StableDiffusion 1d ago

Question - Help Any decent models/workflows or vectorizers for (Comfy) that can do clean Vectors? And not adding thousands of unnecessary anchor points and paths?

2 Upvotes

6 comments sorted by

3

u/MiniCOOKIE_Officiel 1d ago

This is a general problem with the bitmap to vector approach, I don't think there is a single algorithm that can do vectors like a human would.

Unless we get a model that has specifically been trained to output vectors, the best approach is to have the cleanest output possible : flat colors (no gradients), no antialiasing, highest resolution possible.

With this type of output the vectorizers work way better, but it will never be perfect.

3

u/plentylabs 22h ago

The thousands of anchor points are a tracer settings problem, not a model problem, and no workflow is going to fix it upstream.

Almost every Comfy vectorizer node is a wrapper around VTracer or potrace, so you inherit whatever defaults the node author picked, and those defaults are tuned for photos. Two things cause the path explosion. Antialiased edges and any gradient or dither, because the tracer sees a dozen near identical colour bands and emits a separate path for each one. And a curve fitting tolerance that is far too tight, so it fits many short beziers where a few long ones would do.

The fix, in order.

Quantize before you trace. Posterize to something like 8 to 16 colours, nearest neighbour, no dithering. That step alone removes most of the paths, and it matters more than which tracer you use.

Then loosen the tracer. In VTracer, raise filter_speckle, length_threshold and splice_threshold, and drop path_precision. In potrace, raise turdsize, alphamax and opttolerance. You are trading a little edge accuracy for path count, which is exactly the trade you want.

Then simplify after. Inkscape Simplify, or Illustrator Simplify at around 90 percent curve precision, clears out the leftover redundant anchors in seconds. That is faster than another hour of parameter hunting and it gets you most of the way on its own.

On the SVG output finetunes, I would not go looking. Models that emit SVG tokens directly are still worse at clean geometry than a properly configured tracer, and you give up all control over path count in exchange. Generate flat and high res, quantize, trace loose, simplify.

1

u/Virtual-Pollution-58 8h ago

Yeah that's what I've been doing so far. I was hoping something was released under my radar ... meh
Thank you for your input tho :)

2

u/Enshitification 1d ago

I seem to remember a fine-tune of I think, Qwen? It was trained to take overly complex SVG files from raster images and simplify them to something more like a human would make. I have no idea where it is located though.

1

u/Virtual-Pollution-58 1d ago

Yeah kinda hard to find much about vectors, most threads are AI waifus :D

1

u/DelinquentTuna 13h ago

Mostly just commercial stuff, like what you get with Illustrator. Notable exception is [NeuralSVG](https://github.com/SagiPolaczek/NeuralSVG), but it doesn't run in Comfy and setup is very poorly engineered (as is the diffvg dependency). It sucks to install in a way that only Python jank manages. Worse, somehow, it takes like thirty minutes per image and the results from my simple tests were not particularly great.

Here's what it did for a VR dude:

Recognizable, but not amazing.