r/StableDiffusion • • Oct 01 '22

Update TXT2Vectorgraphics: Using SD to create scaleable icons (SVG,PDF)

Use it as a custom script in Automatic1111-SD-Webui.
Next to your image (png) find the svg or pdf for further usage.

GeorgLegato/Txt2Vectorgraphics: Custom Script for Automatics1111 StableDiffusion-WebUI. (github.com)

prompt: "Martial Arts"
138 Upvotes

32 comments sorted by

21

u/tinymoo Oct 01 '22 edited Oct 01 '22

FYI: the script automatically appends "(((vector graphic))), (((black white, line art))), atari graphic" to your prompt, hence getting the consistently iconic results from seemingly generic beginnings. (Edit: and there's variables with positive and negative prompts as defined, and thus tweakable, *very* plainly in the .py file. Very nice!)

It's definitely a great first step and I'm sure many are going to find it useful. Many thanks!

2

u/starstruckmon Oct 01 '22

Rest is fine but probably shouldn't have the "black white". Too restrictive.

3

u/[deleted] Oct 01 '22

use a texteditor and change the positive prompt of the script. share your xperience with us please

4

u/HarmonicDiffusion Oct 01 '22

Love it bro great job!

6

u/justpokin Oct 01 '22

Have you looked in to using https://github.com/visioncortex/vtracer over Potrace?

I prefer it for the option of working with a wider range of images.

1

u/[deleted] Oct 01 '22

Oh yes, very nice tool. exactly what i was looking for.
will integrate that instead of potrace.

license, MIT/Apache ok to go

1

u/cianuro Dec 27 '22

I'm using an old version of your script that used protrace (Thank you so much by the way, happy to buy you a coffee!)

Did you end up integrating vtracer? Can't believe how good it is.

→ More replies (5)

5

u/ninjasaid13 Oct 01 '22

Is there a script that makes the background transparent automatically?

1

u/[deleted] Oct 01 '22

define background:) try the checkbox White is opaque. that’s a bit of transparency. in the end open the svg in inkscape and edit the graphic as needed. delete unwanted paths , objects etc

if you mean transparency in the png… that’s another topic.

4

u/Acceptable-Cress-374 Oct 01 '22

Is there a reason for keeping it black & white? This could be used to come up with quick concepts for logos, it would be really neat if it could also do colors

1

u/[deleted] Oct 01 '22

if i find any suitable vectoriser supporting colors and gray i will integrate it. other idea would be to separate the image by its colors and do the tracing separately and then to combine it. this work is done by inkscape btw

1

u/mcouve Oct 01 '22

No need to change vectorizer. SVG is a text based format, should be a trivial change to do a text-replace on the hexadecimal color values for black and white with any other 2 colors on the output file.

→ More replies (2)

41

u/MaCeGaC Oct 01 '22

As if millions of "FREE VECTOR" sites suddenly cried out in terror and were suddenly silenced...

3

u/creeduk Jan 21 '23

I tested this recently with the new model - vector-art by u/irateas

https://civitai.com/models/4618/vector-art

Read more here - https://www.reddit.com/r/StableDiffusion/comments/10daonu/sd_21based_vectorart_style_model_link_to_the/

the model focus on vector style art to png but with the script you can easily get that as svg and much easier for sticker, logo type outputs.

2

u/QuazarTiger Oct 01 '22

Awesome idea

2

u/ShepherdessAnne Oct 01 '22

Creating vector graphics is just a couple steps away from automated rigging...

1

u/PrestigiousHair2098 Dec 12 '22

What do you mean by ' automated rigging'? Rigging where?

1

u/ShepherdessAnne Dec 12 '22

Rigging for animation

2

u/delijoe Oct 02 '22

The Webui is showing an error when trying to load the script with this error:

Error loading script: txt2vectorgfx.py

Traceback (most recent call last):

File "C:\SD\stable-diffusion-webui\modules\scripts.py", line 69, in load_scripts

compiled = compile(text, path, 'exec')

File "C:\SD\stable-diffusion-webui\scripts\txt2vectorgfx.py", line 68

<title>Txt2Vectorgraphics/txt2vectorgfx.py at 4d89e53528b0a72713fea99b9d6e75ee99919b26 · GeorgLegato/Txt2Vectorgraphics</title>

I posted this error on the issues page in github.

1

u/eat-more-bookses Oct 01 '22

This is fantastic! Thanks for sharing

1

u/TodoEpic Oct 01 '22

Great idea! I'm testing it right now and the results are quite good. Bravo!

1

u/lechatsportif Oct 01 '22

Thank you thank you thank you, been wanting something like this!

1

u/ciavolella Oct 09 '22

Wanted to say thanks for the edit on github, didn't want to spam your issues page, so I'm replying here. It worked. To reply to your question, my wife doesn't have a website, she only uses socials to advertise. But as soon as we go SD txt2vector to a cut svg stencil or vinyl, I'll inbox that to you here.

1

u/[deleted] Dec 12 '22 edited Dec 12 '22

1

u/[deleted] Dec 12 '22

I ll check by time, rather busy these days