SD-webui

코딩으로 처리하는부분을 이해했으니 이제 웹으로 처리하는 부분을 이해해보자.

stable-diffusion-webui 라는 오픈소스 프로젝트를 사용하면 된다.

https://github.com/AUTOMATIC1111/stable-diffusion-webui/tree/master

Dockerfile 생성

FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime

RUN apt update

RUN apt install -y libgl1 wget git curl

RUN DEBIAN_FRONTEND=noninteractive  TZ="America/Los_Angeles" apt install -y libglib2.0-0

WORKDIR /app

RUN git clone --depth 1 --branch v1.7.0 https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

RUN pip install -r stable-diffusion-webui/requirements.txt

# # root 사용 가능하게
RUN sed -i 's/can_run_as_root=0/can_run_as_root=1/g' stable-diffusion-webui/webui.sh

EXPOSE 7860

WORKDIR /app/stable-diffusion-webui

ENTRYPOINT [ "python","launch.py","--listen"]

docker-compose.yaml 생성

version: '3.8'
services:
  sd-webui:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: sd-webui
    restart: unless-stopped
    ports:
      - 7860:7860
    volumes:
      - ./models:/app/stable-diffusion-webui/models
      - ./repositories:/app/stable-diffusion-webui/repositories
      - ./outputs:/app/stable-diffusion-webui/outputs
      - ./embeddings:/app/stable-diffusion-webui/embeddings
    deploy:
      resources:
        reservations:
          devices:
            - driver: 'nvidia'
              capabilities: [gpu]
              count: all

실행

docker-compose up -d

확인

curl http://localhost:7860

![Alt text](images/2. SD-webui/image.png)

option 설명

유투브에 내용이 많으므로 확인해보면될거같다. 기본적인부분은 다음과 같다.

  • prompt : 원하는 이미지를 나타내는 단어

  • negative prompt : 포함되지 않기를 바라는 단어

  • sampling step : 기본 20 낮으면 뭉개짐 높으면 깨끗해짐

  • sampleing method : 조금씩 다름

  • width/height : 가로 / 세로 512가 가장 잘나온다.

  • restore faces : 얼굴이 잘 못나오는걸 보정해준다.

  • tiling : tiling이미지를 만들대 자연스럽게 나오게 한다.

  • Highres : 이상한 요소들을 보정 머리가 두개 등등

  • batch count/ size => 곱한만큼 그림이 나온다.

  • cfg scale : 얼마나 프롬프트를 따라가는지 낮으면 프롬프트랑 상관없이 높으면 프롬프값 그대로

  • seed: 기존 생성한 이미지의 seed값을 넣으면 기존 이미지스타일과 비슷하게 생성된다.

  • script :

    • prompt를 비교해서 표의 형태로 보여준다.

    • 프롬프트 파일을 업로드 된다.

    • x/y plot x축과 y축에 다른 값을 넣어서 화면에서 비교할수 잇게 table로 나온다.

![Alt text](images/2. SD-webui/image-1.png)

  1. 랜덤한 화가의 이름을 넣어줌

  2. 기존 그림에 프롬프트를 가져와서 보여줌

  3. 프롬프트를 저장할수 있음 바로 옆에 로딩할수 잇음

추가 사용법

checkpoint와 lora, vae를 사용하면 더 좋은 이미지를 생성할수 있다.

https://civitai.com 여기에서 모델을 다운받을수 있다.

check point 사용하기

사이트에서 check point model을 받아서 stable-diffusion-webui/models/Stable-diffusion 폴더에 넣어준다. ui에서 refresh를 누르면 파일보인다 사용하면된다.

lora 사용하기

사이트에서 lora를 받아서 stable-diffusion-webui/models/Lora폴더에 넣어준다. ui에서 refresh를 누르면 파일보인다 사용하면된다.

vae 사용하기

사이트에서 vae를 받아서 stable-diffusion-webui/models/VAE폴더에 넣어준다.

ui에서 refresh를 누르면 파일보인다 사용하면된다.

launch.py 옵션

usage: launch.py [-h]
                 [--update-all-extensions]
                 [--skip-python-version-check]
                 [--skip-torch-cuda-test]
                 [--reinstall-xformers]
                 [--reinstall-torch]
                 [--update-check]
                 [--test-server]
                 [--log-startup]
                 [--skip-prepare-environment]
                 [--skip-install]
                 [--dump-sysinfo]
                 [--loglevel LOGLEVEL]
                 [--do-not-download-clip]
                 [--data-dir DATA_DIR]
                 [--config CONFIG]
                 [--ckpt CKPT]
                 [--ckpt-dir CKPT_DIR]
                 [--vae-dir VAE_DIR]
                 [--gfpgan-dir GFPGAN_DIR]
                 [--gfpgan-model GFPGAN_MODEL]
                 [--no-half]
                 [--no-half-vae]
                 [--no-progressbar-hiding]
                 [--max-batch-count MAX_BATCH_COUNT]
                 [--embeddings-dir EMBEDDINGS_DIR]
                 [--textual-inversion-templates-dir TEXTUAL_INVERSION_TEMPLATES_DIR]
                 [--hypernetwork-dir HYPERNETWORK_DIR]
                 [--localizations-dir LOCALIZATIONS_DIR]
                 [--allow-code]
                 [--medvram]
                 [--medvram-sdxl]
                 [--lowvram]
                 [--lowram]
                 [--always-batch-cond-uncond]
                 [--unload-gfpgan]
                 [--precision {full,autocast}]
                 [--upcast-sampling]
                 [--share]
                 [--ngrok NGROK]
                 [--ngrok-region NGROK_REGION]
                 [--ngrok-options NGROK_OPTIONS]
                 [--enable-insecure-extension-access]
                 [--codeformer-models-path CODEFORMER_MODELS_PATH]
                 [--gfpgan-models-path GFPGAN_MODELS_PATH]
                 [--esrgan-models-path ESRGAN_MODELS_PATH]
                 [--bsrgan-models-path BSRGAN_MODELS_PATH]
                 [--realesrgan-models-path REALESRGAN_MODELS_PATH]
                 [--clip-models-path CLIP_MODELS_PATH]
                 [--xformers]
                 [--force-enable-xformers]
                 [--xformers-flash-attention]
                 [--deepdanbooru]
                 [--opt-split-attention]
                 [--opt-sub-quad-attention]
                 [--sub-quad-q-chunk-size SUB_QUAD_Q_CHUNK_SIZE]
                 [--sub-quad-kv-chunk-size SUB_QUAD_KV_CHUNK_SIZE]
                 [--sub-quad-chunk-threshold SUB_QUAD_CHUNK_THRESHOLD]
                 [--opt-split-attention-invokeai]
                 [--opt-split-attention-v1]
                 [--opt-sdp-attention]
                 [--opt-sdp-no-mem-attention]
                 [--disable-opt-split-attention]
                 [--disable-nan-check]
                 [--use-cpu USE_CPU [USE_CPU ...]]
                 [--use-ipex]
                 [--disable-model-loading-ram-optimization]
                 [--listen]
                 [--port PORT]
                 [--show-negative-prompt]
                 [--ui-config-file UI_CONFIG_FILE]
                 [--hide-ui-dir-config]
                 [--freeze-settings]
                 [--ui-settings-file UI_SETTINGS_FILE]
                 [--gradio-debug]
                 [--gradio-auth GRADIO_AUTH]
                 [--gradio-auth-path GRADIO_AUTH_PATH]
                 [--gradio-img2img-tool GRADIO_IMG2IMG_TOOL]
                 [--gradio-inpaint-tool GRADIO_INPAINT_TOOL]
                 [--gradio-allowed-path GRADIO_ALLOWED_PATH]
                 [--opt-channelslast]
                 [--styles-file STYLES_FILE]
                 [--autolaunch]
                 [--theme THEME]
                 [--use-textbox-seed]
                 [--disable-console-progressbars]
                 [--enable-console-prompts]
                 [--vae-path VAE_PATH]
                 [--disable-safe-unpickle]
                 [--api]
                 [--api-auth API_AUTH]
                 [--api-log]
                 [--nowebui]
                 [--ui-debug-mode]
                 [--device-id DEVICE_ID]
                 [--administrator]
                 [--cors-allow-origins CORS_ALLOW_ORIGINS]
                 [--cors-allow-origins-regex CORS_ALLOW_ORIGINS_REGEX]
                 [--tls-keyfile TLS_KEYFILE]
                 [--tls-certfile TLS_CERTFILE]
                 [--disable-tls-verify]
                 [--server-name SERVER_NAME]
                 [--gradio-queue]
                 [--no-gradio-queue]
                 [--skip-version-check]
                 [--no-hashing]
                 [--no-download-sd-model]
                 [--subpath SUBPATH]
                 [--add-stop-route]
                 [--api-server-stop]
                 [--timeout-keep-alive TIMEOUT_KEEP_ALIVE]
                 [--disable-all-extensions]
                 [--disable-extra-extensions]
                 [--skip-load-model-at-start]
                 [--ldsr-models-path LDSR_MODELS_PATH]
                 [--lora-dir LORA_DIR]
                 [--lyco-dir-backcompat LYCO_DIR_BACKCOMPAT]
                 [--scunet-models-path SCUNET_MODELS_PATH]
                 [--swinir-models-path SWINIR_MODELS_PATH]

Last updated

Was this helpful?