GithubHelp home page GithubHelp logo

ayushr6 / sd-webui-automation Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 1.0 47 KB

Easlisy generate images using a datasets/list of prompts, using the automation script for Stable Diffusion web ui.

License: GNU General Public License v3.0

Python 100.00%
ai ai-art automatic1111 automation deep-learning diffusion image-generation pytorch scraper selenium stable-diffusion text2image torch txt2img unstable upscaling web webscraping

sd-webui-automation's Introduction

Automatic1111-webui Automation

A python automated script to automate the AUTOMATIC1111/stable-diffusion-webui, so to ease the task to generate thousands of images, in one go, with the help of csv.

Step 1 - Clone:

  • for HTTPS:
    git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
  • for SSH:
    git clone [email protected]:AUTOMATIC1111/stable-diffusion-webui.git

Step 2 - Installation and Running:

Follow the setps provided in the README to install and run AUTOMATIC1111 - stable diffusion webui

Note 1: After successfull installation, run the webui with the api flag, as follows:-

    bash webui.sh --api

Note 2: After successfully running the webui, note down the URL at which the webui is running. For e.g.

Running on local URL:  http://127.0.0.1:7860

Important: Do not close or exit the terminal, using which sd-webui is running

Step 3 - Clone this repo (in another terminal)

  • for HTTPS:
    git clone https://github.com/ayushr6/sd-webui-automation.git
  • for SSH:
    git clone [email protected]:ayushr6/sd-webui-automation.git

Step 4 - Install required Libraries

  • cd sd-webui-automation

run:

    pip install -r requirements.txt

Step 5 - Setup and Running Script

To list all available models on you end, run the following command:

    python generate_images.py print_available_models

There are two ways through which you can generate images:

1. using two csv files:

  • one, which contains the unique name of actors, items, animals, etc.
  • second, which contains prompts, which contains special characters which can be replaced by the name of a character, item, animal, etc from the initial csv.

Note:- The second csv must also contain the following parameters, replace_with, model_name, sampling_method, sampling_steps, cfg_scale, and batch_count.

for e.g.

first - tiny cute #### toy, soft smooth lighting, soft pastel colors, 3d blender render
second - tiger or camel or any other animal name

prompt = tiny cute tiger toy, soft smooth lighting, soft pastel colors, 3d blender render

This how, we can use two csvs to generate images for a list of characters, animals, etc. and use different prompts for each keyword.

Run:

for webui:

python generate_images.py generate_images_from_two_csv --input_csv "input/animals.csv" --prompt_csv "input/animals_prompts.csv" --headless False --output_dir "output/animals"

for api:

python generate_images.py generate_images_from_two_csv --input_csv "input/animals.csv" --prompt_csv "input/animals_prompts.csv" --use api --output_dir "output/animals"

Parameters

Parameter                 | Definition
------------------------- | -----------------------------------------------------
`--input_csv`             | `path` to `input_csv`
`--prompt_csv`            | `path` to `prompt_csv`
`--webui_url`             | `url` at which `automatic1111-webui` is running
`--model`                 | sd model name (e.g. sd-v1-4)
`--output_dir`            | path to output_dir
`--sampling_method`       | sampling method name (e.g. Eular a, DDIM, etc.)
`--sampling_steps`        | sampling steps (1 - 150)
`--batch_count`           | number of images in one batch (1 - 100)
`--cfg_scale`             | cfg scale (1 - 30)
`--use`                   | accepted values (webui/api)
`--headless`              | run webui in headless mode? (True/False)
`--add_on`                | overwrite existing content or not (`True` / `False`)

2. using a single csv file:

  • This file contains prompts, respect to while we need to generate the images.

Note:- This csv must also contain the following parameters, replace_with, model_name, sampling_method, sampling_steps, cfg_scale, and batch_count.

for e.g.

prompt - tiny cute tiger toy, soft smooth lighting, soft pastel colors, 3d blender render

This how, we can use two csvs to generate images for a list of characters, animals, etc. and use different prompts for each keyword.

Run:

for webui:

python generate_images.py generate_images_from_single_csv --prompt_csv "input/famous_structures.csv" --headless False --output_dir "output/famous_structures"

for api:

python generate_images.py generate_images_from_single_csv --prompt_csv "input/famous_structures.csv" --use api --output_dir "output/famous_structures"

Parameters

Parameter                 | Definition
------------------------- | -----------------------------------------------------
`--prompt_csv`            | `path` to `prompt_csv`
`--webui_url`             | `url` at which `automatic1111-webui` is running
`--model`                 | sd model name (e.g. sd-v1-4)
`--output_dir`            | path to output_dir
`--sampling_method`       | sampling method name (e.g. Eular a, DDIM, etc.)
`--sampling_steps`        | sampling steps (1 - 150)
`--batch_count`           | number of images in one batch (1 - 100)
`--cfg_scale`             | cfg scale (1 - 30)
`--use`                   | accepted values (webui/api)
`--headless`              | run webui in headless mode? (True/False)
`--add_on`                | overwrite existing content or not (`True` / `False`)

CFG Scale : a parameter that controls how much the generated image matches the text prompt and/or the input image. A higher CFG scale value results in an output image more in line with the input prompt or image, but at the expense of quality. Conversely, a lower CFG scale value produces a better-quality image that may differ from the original prompt or image.

Sampling Method/Samplers : Samplers are used to tell the AI how it should start generating visual patterns from the initial noise. NovelAI supports a wide variety of Sampling Methods: DPM++ 2M, Euler Ancestral, Euler, DPM2, DPM++ 2S Ancestral, DPM++ SDE, DPM Fast, and DDIM. (Note: Refer to webui to see list of all samplers)

Sampling Steps : Sampling steps is the number of iterations that Stable Diffusion runs to go from random noise to a recognizable image based on the text prompt.

sd-webui-automation's People

Contributors

ayushr6 avatar

Stargazers

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

Watchers

 avatar

Forkers

mayermakes

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.