Code Monkey home page Code Monkey logo

stable-diffusion-webui-vectorstudio's Introduction

stable-diffusion-webui-vectorstudio

Purpose

  • Adds Javascript-SVG-Editor (SVG-Edit) as a tab to Stable-Diffusion-Webui Automatic 1111.

  • Adds an interactive vectorizer (monochrome and color: "SVGCode" as a further tab

  • Adds postprocessing using POTRACE - executable to mass convert you prompts from png to svg.

  • You can either generate txt2vectorgraphics and finish/edit them in this svg editor

  • Or start drawing in svg editor and send your sketches to Controlnet (txt/img2-img) to a particular control net instance.

Installation

  • Open Extension Tab in SD-Webui and paste this GITHUB-url into the "Install using Url" textbox.
  • On first run, the extension will try to find POTRACE in the bin-folder. If no executable there, it will download the POTRACE (.exe) and copy it into the bin fodler for you. The binary is downloaded from sourceforge like https://potrace.sourceforge.net/#downloading

How it works

It tunes your prompts in that way to create suitable images to be vectorizied by the POTRACE command line tool. The resulting SVG or PDF file is stored next to your png files in output/samples (default).

Examples

prompt PNG SVG
Happy Einstein
Mountainbike Downhill
coffe mug in shape of a heart
Headphones

Screenshot

image image image image

Dark Theme, with SVG-Background checkerboard: image

Features

  • Added SVG-Edit as Tab with "Sendto"-Buttons from Gallery to SVG-Editor and from SVG-Editor your canvas as input for Controlnet!

  • New: Added Visual Styles - RadioButtons provided by the script. Edit the script to extend of modify Stuff like Illustration, Tattoo, Anime etc, to save your time finding prompts on your own. If nothing matches, select "None - promp only" and have back full control.

Recommendations

  • Use short prompts, like "Einstein", "Happy Einstein" ...
  • avoid "realistic" attributes
  • Sampling Steps ~40 is my best experience (to reduce noise and avoid details)
  • CFG Scale 10-12
  • Dont restore faces
  • use 512x512 if no special demand on ratio
  • Batch count support (16)
  • Mostly you want to make white parts opaque (see checkbox in the scripts ui)
  • Same for clipping the content to SVG size
  • HINT: Install Microsoft Powertoys for free, and enjoy in your file explorer SVG previews. image

Using

  • Vector studio is still listed in the script-section: image

  • Three divisons here

    • style buttons(deprecated) -> your your Webui-Styles instead
    • lower left: vector-settings
    • lower right: png2png-settings (quant, set transparent color for poor men)

Edit SVG - Button

Select any created SVG and click below of the gallery the "Edit SVG" button. It sends (by overwriting eveything else) the SVG to the build-in SVG-Edit´or Finish/check your svg for details, and or send back to Controlnet

image

History

  • Added Background-Style dedicated for any SVG-Graphic in WebUI. Default is a checkerbox background to determine what is white shape and what is unfilled. For customizing please edit the file style.css in the extension folder of vectorstudio; either comment in/out white or checker pattern; or whatever you like... image
  • Fix on Controlnet internal images
  • Display SVGs in gallery!

Todos

  • Linux/Mac-Support
  • Settings
  • Rework of the GUI for vectorizing

Note

This extension will replace the simple "txt2vectorgraphics" script. No need for both

stable-diffusion-webui-vectorstudio's People

Contributors

ciphernaut avatar georglegato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stable-diffusion-webui-vectorstudio's Issues

After the image generation fishish it desapear of the

hi,

I got the addon installed and works without a error! but after i generate a image, it simple desapear after finish it! but during the render process thhe image shows up, only after finish the render it desapear! any idea what is happen?
desapear

Appears to run fine but I get no image output. I've tried different models and settings to no avail.

Here is my command window.

Already up to date.
venv "C:\Users\Matt\Stable_new\stable-diffusion-webui\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep 5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)]
Commit hash: 22bcc7be428c94e9408f589966c2040187245d81
Installing requirements for Web UI
Fetching updates for midas...
Checking out commit for midas with hash: 1645b7e...

Installing requirements 1 for Infinite-Zoom

Launching Web UI with arguments: --vae-path models\Stable-diffusion\vae-ft-mse-840000-ema-pruned.pt --api --xformers --disable-safe-unpickle --api --cors-allow-origins=https://www.painthua.com
ControlNet v1.1.107
ControlNet v1.1.107
Loading weights [fe94665ac0] from C:\Users\Matt\Stable_new\stable-diffusion-webui\stable-diffusion-webui\models\Stable-diffusion\vinteprotogenmixV10_.safetensors
Creating model from config: C:\Users\Matt\Stable_new\stable-diffusion-webui\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Loading VAE weights from commandline argument: models\Stable-diffusion\vae-ft-mse-840000-ema-pruned.pt
Applying xformers cross attention optimization.
Textual inversion embeddings loaded(12): atompunkstylesd15, bad-artist-anime, bad-artist, bad-hands-5, bad_prompt_version2, CharTurner, EasyNegative, ghst-3000, logo-with-face-on-shield, ng_deepnegative_v1_75t, poly-hd, Style-Necromancy
Textual inversion embeddings skipped(14): anthro, cartoonish_doll, CGI_Animation, Em_diesel1, InkPunk768, laxpeint, midjourney-1250, mj-csp, nartfixer2_1, nfixer2_1, nrealfixer2_1, remix, SCG768-Euphoria, vray-render
Model loaded in 3.2s (load weights from disk: 0.2s, create model: 0.3s, apply weights to model: 0.5s, apply half(): 0.6s, load VAE: 0.2s, move model to device: 0.6s, load textual inversion embeddings: 0.9s).
Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch().
Startup time: 12.1s (import torch: 1.5s, import gradio: 1.0s, import ldm: 0.4s, other imports: 0.9s, load scripts: 2.0s, load SD checkpoint: 3.5s, create ui: 2.6s, gradio launch: 0.1s).
Loading weights [ee10b26e6c] from C:\Users\Matt\Stable_new\stable-diffusion-webui\stable-diffusion-webui\models\Stable-diffusion\coloringBook_coloringBook.ckpt
Creating model from config: C:\Users\Matt\Stable_new\stable-diffusion-webui\stable-diffusion-webui\models\Stable-diffusion\coloringBook_coloringBook.yaml
LatentDiffusion: Running in v-prediction mode
DiffusionWrapper has 865.91 M params.
Loading VAE weights from commandline argument: models\Stable-diffusion\vae-ft-mse-840000-ema-pruned.pt
Applying xformers cross attention optimization.
Textual inversion embeddings loaded(14): anthro, cartoonish_doll, CGI_Animation, Em_diesel1, InkPunk768, laxpeint, midjourney-1250, mj-csp, nartfixer2_1, nfixer2_1, nrealfixer2_1, remix, SCG768-Euphoria, vray-render
Textual inversion embeddings skipped(12): atompunkstylesd15, bad-artist-anime, bad-artist, bad-hands-5, bad_prompt_version2, CharTurner, EasyNegative, ghst-3000, logo-with-face-on-shield, ng_deepnegative_v1_75t, poly-hd, Style-Necromancy
Model loaded in 2.6s (create model: 0.2s, apply weights to model: 0.6s, apply half(): 0.7s, load VAE: 0.2s, move model to device: 0.9s).
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:04<00:00, 4.46it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:04<00:00, 4.65it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00, 9.25it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00, 9.83it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00, 9.99it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00, 9.91it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 20/20 [00:02<00:00, 10.36it/s]

How vector graphics are presented

Hello, this software is really great, I don't know if the plugin can realize that the generated vector graphics line drawings exist in the form of a separate path (opened in Illustrator), And not in the form of this polygon or many lines, I believe that there will be more directions for use。
For example, the vector image I am generating now exists in the form of this kind of polygon or many lines, and it is impossible to better adjust the shape
image

I don't know if it can be reflected in the form of a line drawing of this path below
lQLPJx2Se4Clh9jNAuHNBgywvdmG3EYcq80EtgzQvkAGAA_1548_737
Thank you so much

that potrace thingy, kindly help!

Have gone through all the related issues already, but even after installing potrace on my ubunutu 22 system with sudo apt-get install potrace and creating soft link with potrace.exe, the generation gives same error

Could you please tell what else I can try? Have tried reinstalling the extension/potrace too. Could you please please help?

ModuleNotFoundError: No module named 'lxml'

On windows:

[stablediffusion_install_dir]\webui-user.bat
Already up to date.
venv "[stablediffusion_install_dir]\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Commit hash: 22bcc7be428c94e9408f589966c2040187245d81
Installing requirements for Web UI


Launching Web UI with arguments: --xformers
Error loading script: pngsvg.py
Traceback (most recent call last):
  File "[stablediffusion_install_dir]\modules\scripts.py", line 256, in load_scripts
    script_module = script_loading.load_module(scriptfile.path)
  File "[stablediffusion_install_dir]\modules\script_loading.py", line 11, in load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "[stablediffusion_install_dir]\extensions\stable-diffusion-webui-vectorstudio\scripts\pngsvg.py", line 2, in <module>
    from lxml import etree
ModuleNotFoundError: No module named 'lxml'

....
pip show lxml
Name: lxml
Version: 4.9.2
Summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
Home-page: https://lxml.de/
Author: lxml dev team
Author-email: [email protected]
License: BSD-3-Clause
Location: c:\python310\lib\site-packages
Requires:
Required-by:

Could you please advise?

requirements.txt missing

Hello,

since the newest update, the plugin is complaining about a missing "requirements.txt" file with the following error message:

Error running install.py for extension C:\StableDiffusion\extensions\stable-diffusion-webui-vectorstudio.
Command: "C:\StableDiffusion\venv\Scripts\python.exe" "C:\StableDiffusion\extensions\stable-diffusion-webui-vectorstudio\install.py"
Error code: 1
stdout:
stderr: Traceback (most recent call last):
File "C:\StableDiffusion\extensions\stable-diffusion-webui-vectorstudio\install.py", line 60, in
reqs = json.load(open(req_file))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\StableDiffusion\extensions\stable-diffusion-webui-vectorstudio\requirements.txt'

Issue after install?

Do I have to change or install something more aside from the github? I get this error Exception: TXT2Vectorgraphics: Execution of Potrace failed, check filesystem, permissions, installation or settings (is image saving on?)
Time taken: 3.30sTorch active/reserved: 3333/3786 MiB, Sys VRAM: 6180/8192 MiB (75.44%)

SVG

I got this error
Exception: TXT2Vectorgraphics: Execution of Potrace failed, check filesystem, permissions, installation or settings (is image saving on?)

Can not work on Mac OS webui, pls help !

can not work on Mac OS webUI:

Error loading script: vectorstudio.py
Traceback (most recent call last):
File "/Users/andyle/stable-diffusion-webui/modules/scripts.py", line 248, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "/Users/andyle/stable-diffusion-webui/modules/script_loading.py", line 11, in load_module
module_spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/Users/andyle/stable-diffusion-webui/extensions/stable-diffusion-webui-vectorstudio/scripts/vectorstudio.py", line 42, in
from tkinter import Image, image_types
File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/init.py", line 37, in
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

Error - Exexution of Potrace failed

The images seems to generate to 100%, but then i get this error and the image is deleted.

Exception: VectorStudio: Execution of Potrace failed, check filesystem, permissions, installation or settings (is image saving on?)

I am using mac m1 pro. I have installed Potrace automatically after the first image generation with vectorstudio and also installed it using homebrew.

Potrace problems under windows

There are two problems with potrace. First it said that 32 bit version cannot be used, and I got this error (and the code says it downloads 64 bits, I don't understand):

Traceback (most recent call last):
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\stable-diffusion-webui-vectorstudio\scripts\vectorstudio.py", line 215, in run
        self.doVector(poFormat, poOpaque, poTight, poKeepPnm, poThreshold, PO_TO_CALL, img, fullofpnm, fullof, mixedImages)
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\stable-diffusion-webui-vectorstudio\scripts\vectorstudio.py", line 231, in doVector
        p2 = subprocess.Popen(args)
      File "C:\Users\Mykee\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 971, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "C:\Users\Mykee\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1456, in _execute_child
        hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
    OSError: [WinError 216] A(z) %1 verziója nem kompatibilis a telepített Windows rendszerrel. Ellenőrizze a rendszerinformációkat, majd lépjen kapcsolatba a szoftver gyártójával

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\modules\txt2img.py", line 52, in txt2img
        processed = modules.scripts.scripts_txt2img.run(p, *args)
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\modules\scripts.py", line 700, in run
        processed = script.run(p, *script_args)
      File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\stable-diffusion-webui-vectorstudio\scripts\vectorstudio.py", line 218, in run
        raise Exception("VectorStudio: Execution of Potrace failed, check filesystem, permissions, installation or settings (is image saving on?)")
    Exception: VectorStudio: Execution of Potrace failed, check filesystem, permissions, installation or settings (is image saving on?)

After I downloaded the 64-bit potrace, then I got this error, it can't handle the path (is cv2.imwrite or cv2.imread in the code? In my experience it does not handle windows routes well, you should use the PIL Image function instead):

I:\Stable-Diffusion-Automatic\stable-diffusion-webui
Total progress: 60it [03:22,  3.37s/it]
Traceback (most recent call last):it/s]
  File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1434, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1335, in postprocess_data
    prediction_value = block.postprocess(prediction_value)
  File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\gradio\components\gallery.py", line 203, in postprocess
    file_path = self.make_temp_copy_if_needed(img)
  File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\gradio\components\base.py", line 226, in make_temp_copy_if_needed
    temp_dir = self.hash_file(file_path)
  File "I:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\gradio\components\base.py", line 190, in hash_file
    with open(file_path, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'I:\\Stable-Diffusion-Automatic\\generated\\txt2img-images\\19815-3146272705.svg'

Didnt fetch 64bit version of Potrace

Just a quick note, maybe could add a check in your autodownloader function to see if system is 64bit, It failed to gen on first run with error about not working on 64bit, easy fix though, I just went & downloaded the 64bit windows potrace file & added to this extensions bin folder.

Thanks for an amazing addon! Im already having tons of creative fun with it. 💚💚💚

API usage

I'm not too worried about stuff like "always on" params and whatnot, but I want to use this with the API, can you explain how? I'm getting no return.

My Input:
{ "prompt": "coloredic0n icon <lora:LOGO_model_0.8 :1.1>, white background, turtle climbing mountain", "steps": 25, "cfg_scale": 7, "width": 512, "height": 512, "script_name": "Vector Studio", "script_args": [ "Logo", "svg", true, true, false, 0.5, false, 16, true, 16 ] }

my response doesn't have an error, but its just an empty image return.

Try using visioncortex/vtracer for vectorization (color support)

I love this library! Thank you, it's a very smart idea.

A suggestion - VTracer is also open source (MIT licence), and could provide better SVG outputs than Potrace, especially for color SD output.

I'd love to be able to do color drawings, but obviously can't with the below output from vectorstudio (an untuned example):
vectorstudio output

In comparison, VTracer is able to output a color SVG:
vtracer color output

Was VTracer tried, in order to support color output? If not, would you consider adding it as an option?

Making This Work In Debian Distro

There are a couple of things needed to make this work in a Debian/Ubuntu distro:

Install potrace:

sudo apt install potrace

Create symlink:

create a folder "bin" in stable-diffusion-webui-vectorstudio
from the command line (shell) in the stable-diffusion-webui-vectorstudio/bin run

ln -s /usr/bin/potrace potrace.exe

In vectorstudio.py make the following change:

# PO_TO_CALL = scripts.basedir() + "\extensions\stable-diffusion-webui-vectorstudio\bin\potrace.exe"
PO_TO_CALL = scripts.basedir() + "/extensions/stable-diffusion-webui-vectorstudio/bin/potrace.exe"

Hope this helps someone.

Invert black and white?

On my results with vector studio script, after the image is generated, my SVG image color appear inverted. Is there a revert it back within the script where black line on the original image are black line on the svg image?

alwayson_scripts parameters for api

Hello,

Great extension thanks!

How would I find the extension parameter references to pass to the API? For example:

"alwayson_scripts": {
"script_name": {
"args": [val1, val2, val3, ..., valN]
}
}

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.