Repository: Sygil-Dev/sygil-webui Branch: master Commit: 15a337cd4377 Files: 290 Total size: 21.8 MB Directory structure: gitextract_lx9je00i/ ├── .dockerignore ├── .env_docker.example ├── .gitattributes ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ └── bug_report.yml │ ├── PULL_REQUEST_TEMPLATE.md │ ├── dependabot.yml │ └── workflows/ │ ├── deploy.yml │ └── test-deploy.yml ├── .gitignore ├── .gitmodules ├── .pre-commit-config.yaml ├── .streamlit/ │ └── config.toml ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile_base ├── Dockerfile_runpod ├── LICENSE ├── README.md ├── Stable_Diffusion_v1_Model_Card.md ├── Web_based_UI_for_Stable_Diffusion_colab.ipynb ├── _config.yml ├── babel.config.js ├── blog/ │ ├── 2022-10-20/ │ │ └── 1.Textual inversion usage competitio.md │ └── authors.yml ├── configs/ │ ├── autoencoder/ │ │ ├── autoencoder_kl_16x16x16.yaml │ │ ├── autoencoder_kl_32x32x4.yaml │ │ ├── autoencoder_kl_64x64x3.yaml │ │ └── autoencoder_kl_8x8x64.yaml │ ├── blip/ │ │ ├── bert_config.json │ │ ├── caption_coco.yaml │ │ ├── med_config.json │ │ ├── nlvr.yaml │ │ ├── nocaps.yaml │ │ ├── pretrain.yaml │ │ ├── retrieval_coco.yaml │ │ ├── retrieval_flickr.yaml │ │ ├── retrieval_msrvtt.yaml │ │ └── vqa.yaml │ ├── latent-diffusion/ │ │ ├── celebahq-ldm-vq-4.yaml │ │ ├── cin-ldm-vq-f8.yaml │ │ ├── cin256-v2.yaml │ │ ├── ffhq-ldm-vq-4.yaml │ │ ├── lsun_bedrooms-ldm-vq-4.yaml │ │ ├── lsun_churches-ldm-kl-8.yaml │ │ └── txt2img-1p4B-eval.yaml │ ├── retrieval-augmented-diffusion/ │ │ └── 768x768.yaml │ ├── stable-diffusion/ │ │ ├── v1-inference.yaml │ │ ├── v2-inference-v.yaml │ │ ├── v2-inference.yaml │ │ ├── v2-inpainting-inference.yaml │ │ ├── v2-midas-inference.yaml │ │ └── x4-upscaling.yaml │ └── webui/ │ ├── webui.yaml │ ├── webui_flet.yaml │ └── webui_streamlit.yaml ├── daisi_app.py ├── data/ │ ├── img2txt/ │ │ ├── artists.txt │ │ ├── flavors.txt │ │ ├── mediums.txt │ │ ├── movements.txt │ │ ├── sites.txt │ │ ├── subreddits.txt │ │ ├── tags.txt │ │ └── techniques.txt │ ├── scn2img_examples/ │ │ ├── cat_at_beach.scn2img.md │ │ ├── corgi_3d_transformation.scn2img.md │ │ ├── corgi_at_beach.scn2img.md │ │ ├── corgi_at_beach_2.scn2img.md │ │ └── landscape_3d.scn2img.md │ └── tags/ │ ├── config.json │ ├── danbooru.csv │ ├── e621.csv │ ├── key_phrases.json │ └── thumbnails.json ├── docker-compose.yml ├── docs/ │ ├── 1.Installation/ │ │ ├── 1.one-click-installer.md │ │ ├── 2.windows-installation.md │ │ ├── 3.linux-installation.md │ │ └── 4.docker-guide.md │ ├── 2.Streamlit/ │ │ └── 1.streamlit-interface.md │ ├── 3.Gradio/ │ │ └── 2.gradio-interface.md │ ├── 4.post-processing.md │ ├── 5.concepts-library.md │ └── 6.custom-models.md ├── docusaurus.config.js ├── entrypoint.sh ├── environment.yaml ├── frontend/ │ ├── .eslintrc.js │ ├── __init__.py │ ├── css/ │ │ ├── custom.css │ │ ├── docs_custom.css │ │ ├── no_progress_bar.css │ │ ├── streamlit.main.css │ │ └── styles.css │ ├── css_and_js.py │ ├── dists/ │ │ ├── concept-browser/ │ │ │ └── dist/ │ │ │ ├── assets/ │ │ │ │ ├── index.3ab9729b.css │ │ │ │ └── index.b5b962e4.js │ │ │ └── index.html │ │ └── sd-gallery/ │ │ └── dist/ │ │ ├── assets/ │ │ │ ├── index.4194368f.css │ │ │ └── index.aeaed602.js │ │ └── index.html │ ├── frontend.py │ ├── image_metadata.py │ ├── index.html │ ├── job_manager.py │ ├── js/ │ │ └── index.js │ ├── package.json │ ├── src/ │ │ ├── Component.vue │ │ ├── app.vue │ │ ├── env.d.ts │ │ ├── main.ts │ │ └── streamlit/ │ │ ├── StreamlitVue.ts │ │ ├── WithStreamlitConnection.vue │ │ └── index.ts │ ├── tsconfig.json │ ├── tsconfig.node.json │ ├── ui_functions.py │ └── vite.config.ts ├── horde_bridge.cmd ├── horde_bridge.sh ├── installer/ │ ├── create_installers.sh │ ├── install.bat │ └── install.sh ├── ldm/ │ ├── __init__.py │ ├── data/ │ │ ├── __init__.py │ │ ├── base.py │ │ ├── coco_karpathy_dataset.py │ │ ├── flickr30k_dataset.py │ │ ├── imagenet.py │ │ ├── lsun.py │ │ ├── nlvr_dataset.py │ │ ├── nocaps_dataset.py │ │ ├── personalized.py │ │ ├── personalized_file.py │ │ ├── pretrain_dataset.py │ │ ├── util.py │ │ ├── video_dataset.py │ │ └── vqa_dataset.py │ ├── devices/ │ │ ├── __init__.py │ │ └── devices.py │ ├── lr_scheduler.py │ ├── models/ │ │ ├── __init__.py │ │ ├── autoencoder.py │ │ ├── blip.py │ │ ├── blip_itm.py │ │ ├── blip_nlvr.py │ │ ├── blip_pretrain.py │ │ ├── blip_retrieval.py │ │ ├── blip_vqa.py │ │ ├── diffusion/ │ │ │ ├── __init__.py │ │ │ ├── classifier.py │ │ │ ├── ddim.py │ │ │ ├── ddpm.py │ │ │ ├── dpm_solver/ │ │ │ │ ├── __init__.py │ │ │ │ ├── dpm_solver.py │ │ │ │ └── sampler.py │ │ │ ├── kdiffusion.py │ │ │ ├── plms.py │ │ │ └── sampling_util.py │ │ ├── med.py │ │ ├── nlvr_encoder.py │ │ └── vit.py │ ├── modules/ │ │ ├── __init__.py │ │ ├── attention.py │ │ ├── diffusionmodules/ │ │ │ ├── __init__.py │ │ │ ├── model.py │ │ │ ├── openaimodel.py │ │ │ ├── upscaling.py │ │ │ └── util.py │ │ ├── distributions/ │ │ │ ├── __init__.py │ │ │ └── distributions.py │ │ ├── ema.py │ │ ├── embedding_manager.py │ │ ├── encoders/ │ │ │ ├── __init__.py │ │ │ └── modules.py │ │ ├── image_degradation/ │ │ │ ├── __init__.py │ │ │ ├── bsrgan.py │ │ │ ├── bsrgan_light.py │ │ │ └── utils_image.py │ │ ├── losses/ │ │ │ ├── __init__.py │ │ │ ├── contperceptual.py │ │ │ └── vqperceptual.py │ │ ├── midas/ │ │ │ ├── api.py │ │ │ ├── midas/ │ │ │ │ ├── __init__.py │ │ │ │ ├── base_model.py │ │ │ │ ├── blocks.py │ │ │ │ ├── dpt_depth.py │ │ │ │ ├── midas_net.py │ │ │ │ ├── midas_net_custom.py │ │ │ │ ├── transforms.py │ │ │ │ └── vit.py │ │ │ └── utils.py │ │ └── x_transformer.py │ └── util.py ├── optimizedSD/ │ ├── ddpm.py │ ├── diffusers_txt2img.py │ ├── openaimodelSplit.py │ ├── optimUtils.py │ ├── optimized_img2img.py │ ├── optimized_txt2img.py │ ├── samplers.py │ ├── splitAttention.py │ └── v1-inference.yaml ├── package.json ├── requirements.txt ├── runpod_entrypoint.sh ├── scripts/ │ ├── APIServer.py │ ├── ModelManager.py │ ├── Settings.py │ ├── __init__.py │ ├── barfi_baklavajs.py │ ├── bridgeData_template.py │ ├── clip_interrogator.py │ ├── convert_original_stable_diffusion_to_diffusers.py │ ├── custom_components/ │ │ ├── draggable_number_input/ │ │ │ ├── __init__.py │ │ │ └── main.js │ │ └── sygil_suggestions/ │ │ ├── __init__.py │ │ ├── main.css │ │ ├── main.js │ │ └── parent.css │ ├── diffusers_textual_inversion_2.py │ ├── home.py │ ├── hydrus_api/ │ │ ├── __init__.py │ │ └── utils.py │ ├── img2img.py │ ├── img2txt.py │ ├── imglab.py │ ├── logger.py │ ├── merge.py │ ├── modeldownload.py │ ├── perlin.py │ ├── pipelines/ │ │ └── stable_diffusion/ │ │ └── no_check.py │ ├── post_processing.py │ ├── prune-ckpt.py │ ├── relauncher.py │ ├── scn2img.py │ ├── sd_concept_library.py │ ├── sd_concepts_library_downloader.py │ ├── sd_utils/ │ │ ├── __init__.py │ │ └── bridge.py │ ├── sd_utils_old.py │ ├── stable_diffusion_pipeline.py │ ├── textual_inversion.py │ ├── txt2img.py │ ├── txt2vid.py │ ├── webui.py │ ├── webui_streamlit.py │ └── webui_streamlit_new.py ├── setup.py ├── sidebars.js ├── streamlit_webview.py ├── webui/ │ ├── flet/ │ │ ├── assets/ │ │ │ └── manifest.json │ │ ├── scripts/ │ │ │ ├── __init__.py │ │ │ ├── flet_asset_manager.py │ │ │ ├── flet_canvas.py │ │ │ ├── flet_file_manager.py │ │ │ ├── flet_gallery_window.py │ │ │ ├── flet_messages.py │ │ │ ├── flet_property_manager.py │ │ │ ├── flet_settings_window.py │ │ │ ├── flet_titlebar.py │ │ │ ├── flet_tool_manager.py │ │ │ └── flet_utils.py │ │ └── webui_flet.py │ └── streamlit/ │ ├── frontend/ │ │ └── css/ │ │ └── streamlit.main.css │ └── scripts/ │ ├── APIServer.py │ ├── ModelManager.py │ ├── Settings.py │ ├── barfi_baklavajs.py │ ├── custom_components/ │ │ ├── dragable_number_input/ │ │ │ └── index.html │ │ ├── draggable_number_input/ │ │ │ ├── __init__.py │ │ │ └── main.js │ │ └── sygil_suggestions/ │ │ ├── __init__.py │ │ ├── main.css │ │ ├── main.js │ │ └── parent.css │ ├── img2img.py │ ├── img2txt.py │ ├── post_processing.py │ ├── sd_concept_library.py │ ├── sd_utils/ │ │ ├── __init__.py │ │ └── bridge.py │ ├── textual_inversion.py │ ├── txt2img.py │ ├── txt2vid.py │ └── webui_streamlit.py ├── webui.cmd ├── webui.sh └── webui_legacy.cmd ================================================ FILE CONTENTS ================================================ ================================================ FILE: .dockerignore ================================================ outputs/ src/ configs/webui/userconfig_streamlit.yaml ================================================ FILE: .env_docker.example ================================================ # Force miniconda to attempt to update on every container restart # instead only when changes are detected CONDA_FORCE_UPDATE=false # Validate the model files on every container restart # (useful to set to false after you're sure the model files are already in place) VALIDATE_MODELS=true #Automatically relaunch the webui on crashes WEBUI_RELAUNCH=true #Pass cli arguments to webui.py e.g: #WEBUI_ARGS=--gpu=1 --esrgan-gpu=1 --gfpgan-gpu=1 WEBUI_ARGS= ================================================ FILE: .gitattributes ================================================ * text=auto *.{cmd,[cC][mM][dD]} text eol=crlf *.{bat,[bB][aA][tT]} text eol=crlf *.sh text eol=lf ================================================ FILE: .github/FUNDING.yml ================================================ github: [ZeroCool940711] patreon: zerocool94 ko_fi: zerocool94 open_collective: sygil_dev custom: ["https://paypal.me/zerocool94"] ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.yml ================================================ name: 🐞 Bug Report description: File a bug report title: "[Bug]: " labels: ["bug", "triage"] assignees: - octocat body: - type: markdown attributes: value: | Thanks for taking the time to fill out this bug report! - type: textarea id: what-happened attributes: label: What happened? description: Also tell us, what did you expect to happen? placeholder: Tell us what you see! value: "A bug happened!" validations: required: true - type: dropdown id: version attributes: label: Version description: What version of our software are you running? options: - 0.0.1 (Default) validations: required: true - type: dropdown id: browsers attributes: label: What browsers are you seeing the problem on? multiple: true options: - Firefox - Chrome - Safari - Microsoft Edge - type: dropdown id: os attributes: label: Where are you running the webui? multiple: true options: - Windows - Colab - Linux - MacOS - type: textarea id: settings attributes: label: Custom settings description: If you are running the webui with specifi settings, please paste them here for reference (like --nitro) render: shell - type: textarea id: logs attributes: label: Relevant log output description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. render: shell - type: checkboxes id: terms attributes: label: Code of Conduct description: By submitting this issue, you agree to follow our [Code of Conduct](https://docs.github.com/en/site-policy/github-terms/github-community-code-of-conduct) options: - label: I agree to follow this project's Code of Conduct required: true ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ # Description Please include: * relevant motivation * a summary of the change * which issue is fixed. * any additional dependencies that are required for this change. Closes: # (issue) # Checklist: - [ ] I have changed the base branch to `dev` - [ ] I have performed a self-review of my own code - [ ] I have commented my code in hard-to-understand areas - [ ] I have made corresponding changes to the documentation ================================================ FILE: .github/dependabot.yml ================================================ # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: "pip" # See documentation for possible values directory: "/" # Location of package manifests target-branch: "dev" schedule: interval: "daily" ================================================ FILE: .github/workflows/deploy.yml ================================================ name: Deploy to GitHub Pages on: push: branches: - master # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on jobs: deploy: name: Deploy to GitHub Pages runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: node-version: 18 cache: yarn - name: Install dependencies run: yarn install - name: Build website run: yarn build # Popular action to deploy to GitHub Pages: # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} # Build output to publish to the `gh-pages` branch: publish_dir: ./build # The following lines assign commit authorship to the official # GH-Actions bot for deploys to `gh-pages` branch: # https://github.com/actions/checkout/issues/13#issuecomment-724415212 # The GH actions bot is used by default if you didn't specify the two fields. # You can swap them out with your own user credentials. user_name: github-actions[bot] user_email: 41898282+github-actions[bot]@users.noreply.github.com ================================================ FILE: .github/workflows/test-deploy.yml ================================================ name: Test deployment on: pull_request: branches: - master # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on jobs: test-deploy: name: Test deployment runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: node-version: 18 cache: yarn - name: Install dependencies run: yarn install - name: Test build website run: yarn build ================================================ FILE: .gitignore ================================================ # OS-generated # ------------ .DS_Store* [Tt]humbs.db [Dd]esktop.ini # Programming - general *.log # =========================================================================== # # Python-related # =========================================================================== # # src: https://github.com/github/gitignore/blob/master/Python.gitignore # JetBrains PyCharm / Rider .idea/ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST .env_docker .env_updated condaenv.*.requirements.txt # Visual Studio directories .vs/ .vscode/ # =========================================================================== # # Repo-specific # =========================================================================== # /configs/webui/userconfig_streamlit.yaml /configs/webui/userconfig_flet.yaml /custom-conda-path.txt !/src/components/* !/src/pages/* /src/* /outputs /model_cache /log/**/*.png /log/webui/* /log/log.csv /flagged/* /gfpgan/* /models/* /webui/flet/assets/uploads/ /webui/flet/assets/outputs/ z_version_env.tmp scripts/bridgeData.py /user_data/* # Dependencies /node_modules # Production /build # Generated files .docusaurus .cache-loader # Misc .DS_Store .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* ================================================ FILE: .gitmodules ================================================ ================================================ FILE: .pre-commit-config.yaml ================================================ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks ci: autofix_prs: true autoupdate_branch: 'dev' autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_schedule: weekly repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/astral-sh/ruff-pre-commit rev: "v0.0.278" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black rev: 23.7.0 hooks: - id: black ================================================ FILE: .streamlit/config.toml ================================================ [global] disableWatchdogWarning = false showWarningOnDirectExecution = true dataFrameSerialization = "arrow" [logger] level = "info" messageFormat = "%(asctime)s %(message)s" [client] caching = true displayEnabled = true showErrorDetails = true [runner] magicEnabled = true installTracer = false fixMatplotlib = true postScriptGC = true fastReruns = false [server] folderWatchBlacklist = [] fileWatcherType = "auto" cookieSecret = "" headless = false runOnSave = false port = 8501 baseUrlPath = "" enableCORS = true enableXsrfProtection = true maxUploadSize = 200 maxMessageSize = 200 enableWebsocketCompression = false [browser] gatherUsageStats = false serverPort = 8501 [mapbox] token = "" [deprecation] showfileUploaderEncoding = true showPyplotGlobalUse = true [theme] base = "dark" ================================================ FILE: CONTRIBUTING.md ================================================ # Contribution Guide All Pull Requests are opened against `dev` branch which is our main development branch. There are two UI systems that are supported currently: * **Gradio** — entry point is in the `/scripts/webui.py` you can start from there. Check out [Gradio documentation](https://gradio.app/docs/) and their [Discord channel](https://discord.gg/Qs8AsnX7Jd) for more information about Gradio. * **Streamlit** — entry point is in the `/scripts/webui_streamlit.py`. Documentation on Streamlit is [located here](https://docs.streamlit.io/). ### Development environment `environment.yaml` can be different from the one on `master` so be sure to update before making any changes to the code. The development environment is currently very similar to the one in production, so you can work on your contribution in the same conda env. Optionally you can create a separate environment. ### Making changes If you're working on a fix please post about it in the respective issue. If the issue doesn't exist create it and then mention it in your Pull Request. If you're introducing new features please make the corresponding additions to the documentation with an explanation of the new behavior. The documentation is located in `/docs/`. Depending on your contribution you may edit the existing files in there or create a new one. ### Opening a Pull Request Prior to opening a request make sure your Web UI works locally with your changes and that your branch is up-to-date with the main repository. Finally, open a new PR against `dev` branch. ================================================ FILE: Dockerfile ================================================ ARG IMAGE=tukirito/sygil-webui:base # Use the base image FROM ${IMAGE} # Set the working directory WORKDIR /workdir # Use the specified shell SHELL ["/bin/bash", "-c"] # Set environment variables ENV PYTHONPATH=/sd # Expose the required port EXPOSE 8501 # Copy necessary files and directories COPY ./entrypoint.sh /sd/ COPY ./data/DejaVuSans.ttf /usr/share/fonts/truetype/ COPY ./data /sd/data COPY ./images /sd/images COPY ./scripts /sd/scripts COPY ./ldm /sd/ldm COPY ./frontend /sd/frontend COPY ./configs /sd/configs COPY ./configs/webui/webui_streamlit.yaml /sd/configs/webui/userconfig_streamlit.yaml COPY ./.streamlit /sd/.streamlit COPY ./optimizedSD /sd/optimizedSD # Set the entrypoint ENTRYPOINT ["/sd/entrypoint.sh"] # Create .streamlit directory and set up credentials.toml RUN mkdir -p ~/.streamlit \ && echo "[general]" > ~/.streamlit/credentials.toml \ && echo "email = \"\"" >> ~/.streamlit/credentials.toml ================================================ FILE: Dockerfile_base ================================================ ARG PYTORCH_IMAGE=hlky/pytorch:1.12.1-runtime FROM ${PYTORCH_IMAGE} SHELL ["/bin/bash", "-c"] WORKDIR /install RUN apt-get update && \ apt-get install -y wget curl git build-essential zip unzip nano openssh-server libgl1 libsndfile1-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* COPY ./requirements.txt /install/ COPY ./setup.py /install/ RUN /opt/conda/bin/python -m pip install -r /install/requirements.txt RUN /opt/conda/bin/conda clean -ya ================================================ FILE: Dockerfile_runpod ================================================ ARG IMAGE=tukirito/sygil-webui:base FROM ${IMAGE} WORKDIR /workdir SHELL ["/bin/bash", "-c"] ENV PYTHONPATH=/sd EXPOSE 8501 COPY ./runpod_entrypoint.sh /sd/entrypoint.sh COPY ./data/DejaVuSans.ttf /usr/share/fonts/truetype/ COPY ./configs/ /sd/configs/ copy ./configs/webui/webui_streamlit.yaml /sd/configs/webui/userconfig_streamlit.yaml COPY ./data/ /sd/data/ COPY ./frontend/ /sd/frontend/ COPY ./gfpgan/ /sd/gfpgan/ COPY ./images/ /sd/images/ COPY ./ldm/ /sd/ldm/ COPY ./models/ /sd/models/ copy ./optimizedSD/ /sd/optimizedSD/ COPY ./scripts/ /sd/scripts/ COPY ./.streamlit/ /sd/.streamlit/ ENTRYPOINT /sd/entrypoint.sh RUN mkdir -p ~/.streamlit/ RUN echo "[general]" > ~/.streamlit/credentials.toml RUN echo "email = \"\"" >> ~/.streamlit/credentials.toml ================================================ FILE: LICENSE ================================================ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . ================================================ FILE: README.md ================================================ #
Web-based UI for Stable Diffusion
## Created by [Sygil.Dev](https://github.com/sygil-dev) ## Join us at Sygil.Dev's Discord Server [![Generic badge](https://flat.badgen.net/discord/members/ttM8Tm6wge?icon=discord)](https://discord.gg/ttM8Tm6wge) ## Installation instructions for: - **[Windows](https://sygil-dev.github.io/sygil-webui/docs/Installation/windows-installation)** - **[Linux](https://sygil-dev.github.io/sygil-webui/docs/Installation/linux-installation)** ### Want to ask a question or request a feature? Come to our [Discord Server](https://discord.gg/gyXNe4NySY) or use [Discussions](https://github.com/sygil-dev/sygil-webui/discussions). ## Documentation [Documentation is located here](https://sygil-dev.github.io/sygil-webui/) ## Want to contribute? Check the [Contribution Guide](CONTRIBUTING.md) [Sygil-Dev](https://github.com/Sygil-Dev) main devs: * ![ZeroCool940711's avatar](https://avatars.githubusercontent.com/u/5977640?s=40&v=4)[ZeroCool940711](https://github.com/ZeroCool940711) * ![Kasiya13's avatar](https://avatars.githubusercontent.com/u/26075839?s=40&v=4)[Kasiya13](https://github.com/Kasiya13) ### Project Features: * Built-in image enhancers and upscalers, including GFPGAN and realESRGAN * Generator Preview: See your image as its being made * Run additional upscaling models on CPU to save VRAM * Textual inversion: [Reaserch Paper](https://textual-inversion.github.io/) * K-Diffusion Samplers: A great collection of samplers to use, including: - `k_euler` - `k_lms` - `k_euler_a` - `k_dpm_2` - `k_dpm_2_a` - `k_heun` - `PLMS` - `DDIM` * Loopback: Automatically feed the last generated sample back into img2img * Prompt Weighting & Negative Prompts: Gain more control over your creations * Selectable GPU usage from Settings tab * Word Seeds: Use words instead of seed numbers * Automated Launcher: Activate conda and run Stable Diffusion with a single command * Lighter on VRAM: 512x512 Text2Image & Image2Image tested working on 4GB (with *optimized* mode enabled in Settings) * Prompt validation: If your prompt is too long, you will get a warning in the text output field * Sequential seeds for batches: If you use a seed of 1000 to generate two batches of two images each, four generated images will have seeds: `1000, 1001, 1002, 1003`. * Prompt matrix: Separate multiple prompts using the `|` character, and the system will produce an image for every combination of them. * [Gradio] Advanced img2img editor with Mask and crop capabilities * [Gradio] Mask painting 🖌️: Powerful tool for re-generating only specific parts of an image you want to change (currently Gradio only) # SD WebUI An easy way to work with Stable Diffusion right from your browser. ## Streamlit ![](images/streamlit/streamlit-t2i.png) **Features:** - Clean UI with an easy to use design, with support for widescreen displays - *Dynamic live preview* of your generations - Easily customizable defaults, right from the WebUI's Settings tab - An integrated gallery to show the generations for a prompt - *Optimized VRAM* usage for bigger generations or usage on lower end GPUs - *Text to Video:* Generate video clips from text prompts right from the WebUI (WIP) - Image to Text: Use [CLIP Interrogator](https://github.com/pharmapsychotic/clip-interrogator) to interrogate an image and get a prompt that you can use to generate a similar image using Stable Diffusion. - *Concepts Library:* Run custom embeddings others have made via textual inversion. - Textual Inversion training: Train your own embeddings on any photo you want and use it on your prompt. - **Currently in development: [Stable Horde](https://stablehorde.net/) integration; ImgLab, batch inputs, & mask editor from Gradio **Prompt Weights & Negative Prompts:** To give a token (tag recognized by the AI) a specific or increased weight (emphasis), add `:0.##` to the prompt, where `0.##` is a decimal that will specify the weight of all tokens before the colon. Ex: `cat:0.30, dog:0.70` or `guy riding a bicycle :0.7, incoming car :0.30` Negative prompts can be added by using `###` , after which any tokens will be seen as negative. Ex: `cat playing with string ### yarn` will negate `yarn` from the generated image. Negatives are a very powerful tool to get rid of contextually similar or related topics, but **be careful when adding them since the AI might see connections you can't**, and end up outputting gibberish **Tip:* Try using the same seed with different prompt configurations or weight values see how the AI understands them, it can lead to prompts that are more well-tuned and less prone to error. Please see the [Streamlit Documentation](docs/4.streamlit-interface.md) to learn more. ## Gradio [Legacy] ![](images/gradio/gradio-t2i.png) **Features:** - Older UI that is functional and feature complete. - Has access to all upscaling models, including LSDR. - Dynamic prompt entry automatically changes your generation settings based on `--params` in a prompt. - Includes quick and easy ways to send generations to Image2Image or the Image Lab for upscaling. **Note: the Gradio interface is no longer being actively developed by Sygil.Dev and is only receiving bug fixes.** Please see the [Gradio Documentation](https://sygil-dev.github.io/sygil-webui/docs/Gradio/gradio-interface/) to learn more. ## Image Upscalers --- ### GFPGAN ![](images/GFPGAN.png) Lets you improve faces in pictures using the GFPGAN model. There is a checkbox in every tab to use GFPGAN at 100%, and also a separate tab that just allows you to use GFPGAN on any picture, with a slider that controls how strong the effect is. If you want to use GFPGAN to improve generated faces, you need to install it separately. Download [GFPGANv1.4.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth) and put it into the `/sygil-webui/models/gfpgan` directory. ### RealESRGAN ![](images/RealESRGAN.png) Lets you double the resolution of generated images. There is a checkbox in every tab to use RealESRGAN, and you can choose between the regular upscaler and the anime version. There is also a separate tab for using RealESRGAN on any picture. Download [RealESRGAN_x4plus.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) and [RealESRGAN_x4plus_anime_6B.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth). Put them into the `sygil-webui/models/realesrgan` directory. ### LSDR Download **LDSR** [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename `last.ckpt` to `model.ckpt` and place both under `sygil-webui/models/ldsr/` ### GoBig, and GoLatent *(Currently on the Gradio version Only)* More powerful upscalers that uses a separate Latent Diffusion model to more cleanly upscale images. Please see the [Post-Processing Documentation](https://sygil-dev.github.io/sygil-webui/docs/post-processing) to learn more. ----- ### *Original Information From The Stable Diffusion Repo:* # Stable Diffusion *Stable Diffusion was made possible thanks to a collaboration with [Stability AI](https://stability.ai/) and [Runway](https://runwayml.com/) and builds upon our previous work:* [**High-Resolution Image Synthesis with Latent Diffusion Models**](https://ommer-lab.com/research/latent-diffusion-models/) [Robin Rombach](https://github.com/rromb)\*, [Andreas Blattmann](https://github.com/ablattmann)\*, [Dominik Lorenz](https://github.com/qp-qp)\, [Patrick Esser](https://github.com/pesser), [Björn Ommer](https://hci.iwr.uni-heidelberg.de/Staff/bommer) **CVPR '22 Oral** which is available on [GitHub](https://github.com/CompVis/latent-diffusion). PDF at [arXiv](https://arxiv.org/abs/2112.10752). Please also visit our [Project page](https://ommer-lab.com/research/latent-diffusion-models/). [Stable Diffusion](#stable-diffusion-v1) is a latent text-to-image diffusion model. Thanks to a generous compute donation from [Stability AI](https://stability.ai/) and support from [LAION](https://laion.ai/), we were able to train a Latent Diffusion Model on 512x512 images from a subset of the [LAION-5B](https://laion.ai/blog/laion-5b/) database. Similar to Google's [Imagen](https://arxiv.org/abs/2205.11487), this model uses a frozen CLIP ViT-L/14 text encoder to condition the model on text prompts. With its 860M UNet and 123M text encoder, the model is relatively lightweight and runs on a GPU with at least 10GB VRAM. See [this section](#stable-diffusion-v1) below and the [model card](https://huggingface.co/CompVis/stable-diffusion). ## Stable Diffusion v1 Stable Diffusion v1 refers to a specific configuration of the model architecture that uses a downsampling-factor 8 autoencoder with an 860M UNet and CLIP ViT-L/14 text encoder for the diffusion model. The model was pretrained on 256x256 images and then finetuned on 512x512 images. *Note: Stable Diffusion v1 is a general text-to-image diffusion model and therefore mirrors biases and (mis-)conceptions that are present in its training data. Details on the training procedure and data, as well as the intended use of the model can be found in the corresponding [model card](https://huggingface.co/CompVis/stable-diffusion). ## Comments - Our code base for the diffusion models builds heavily on [OpenAI's ADM codebase](https://github.com/openai/guided-diffusion) and [https://github.com/lucidrains/denoising-diffusion-pytorch](https://github.com/lucidrains/denoising-diffusion-pytorch). Thanks for open-sourcing! - The implementation of the transformer encoder is from [x-transformers](https://github.com/lucidrains/x-transformers) by [lucidrains](https://github.com/lucidrains?tab=repositories). ## BibTeX ``` @misc{rombach2021highresolution, title={High-Resolution Image Synthesis with Latent Diffusion Models}, author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer}, year={2021}, eprint={2112.10752}, archivePrefix={arXiv}, primaryClass={cs.CV} } ``` ================================================ FILE: Stable_Diffusion_v1_Model_Card.md ================================================ # Stable Diffusion v1 Model Card This model card focuses on the model associated with the Stable Diffusion model, available [here](https://github.com/CompVis/stable-diffusion). ## Model Details - **Developed by:** Robin Rombach, Patrick Esser - **Model type:** Diffusion-based text-to-image generation model - **Language(s):** English - **License:** [Proprietary](LICENSE) - **Model Description:** This is a model that can be used to generate and modify images based on text prompts. It is a [Latent Diffusion Model](https://arxiv.org/abs/2112.10752) that uses a fixed, pretrained text encoder ([CLIP ViT-L/14](https://arxiv.org/abs/2103.00020)) as suggested in the [Imagen paper](https://arxiv.org/abs/2205.11487). - **Resources for more information:** [GitHub Repository](https://github.com/CompVis/stable-diffusion), [Paper](https://arxiv.org/abs/2112.10752). - **Cite as:** @InProceedings{Rombach_2022_CVPR, author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn}, title = {High-Resolution Image Synthesis With Latent Diffusion Models}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, month = {June}, year = {2022}, pages = {10684-10695} } # Uses ## Direct Use The model is intended for research purposes only. Possible research areas and tasks include - Safe deployment of models which have the potential to generate harmful content. - Probing and understanding the limitations and biases of generative models. - Generation of artworks and use in design and other artistic processes. - Applications in educational or creative tools. - Research on generative models. Excluded uses are described below. ### Misuse, Malicious Use, and Out-of-Scope Use _Note: This section is taken from the [DALLE-MINI model card](https://huggingface.co/dalle-mini/dalle-mini), but applies in the same way to Stable Diffusion v1_. The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes. #### Out-of-Scope Use The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model. #### Misuse and Malicious Use Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to: - Generating demeaning, dehumanizing, or otherwise harmful representations of people or their environments, cultures, religions, etc. - Intentionally promoting or propagating discriminatory content or harmful stereotypes. - Impersonating individuals without their consent. - Sexual content without consent of the people who might see it. - Mis- and disinformation - Representations of egregious violence and gore - Sharing of copyrighted or licensed material in violation of its terms of use. - Sharing content that is an alteration of copyrighted or licensed material in violation of its terms of use. ## Limitations and Bias ### Limitations - The model does not achieve perfect photorealism - The model cannot render legible text - The model does not perform well on more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere” - Faces and people in general may not be generated properly. - The model was trained mainly with English captions and will not work as well in other languages. - The autoencoding part of the model is lossy - The model was trained on a large-scale dataset [LAION-5B](https://laion.ai/blog/laion-5b/) which contains adult material and is not fit for product use without additional safety mechanisms and considerations. ### Bias While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases. Stable Diffusion v1 was trained on subsets of [LAION-2B(en)](https://laion.ai/blog/laion-5b/), which consists of images that are primarily limited to English descriptions. Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for. This affects the overall output of the model, as white and western cultures are often set as the default. Further, the ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts. ## Training **Training Data** The model developers used the following dataset for training the model: - LAION-2B (en) and subsets thereof (see next section) **Training Procedure** Stable Diffusion v1 is a latent diffusion model which combines an autoencoder with a diffusion model that is trained in the latent space of the autoencoder. During training, - Images are encoded through an encoder, which turns images into latent representations. The autoencoder uses a relative downsampling factor of 8 and maps images of shape H x W x 3 to latents of shape H/f x W/f x 4 - Text prompts are encoded through a ViT-L/14 text-encoder. - The non-pooled output of the text encoder is fed into the UNet backbone of the latent diffusion model via cross-attention. - The loss is a reconstruction objective between the noise that was added to the latent and the prediction made by the UNet. We currently provide three checkpoints, `sd-v1-1.ckpt`, `sd-v1-2.ckpt` and `sd-v1-3.ckpt`, which were trained as follows, - `sd-v1-1.ckpt`: 237k steps at resolution `256x256` on [laion2B-en](https://huggingface.co/datasets/laion/laion2B-en). 194k steps at resolution `512x512` on [laion-high-resolution](https://huggingface.co/datasets/laion/laion-high-resolution) (170M examples from LAION-5B with resolution `>= 1024x1024`). - `sd-v1-2.ckpt`: Resumed from `sd-v1-1.ckpt`. 515k steps at resolution `512x512` on "laion-improved-aesthetics" (a subset of laion2B-en, filtered to images with an original size `>= 512x512`, estimated aesthetics score `> 5.0`, and an estimated watermark probability `< 0.5`. The watermark estimate is from the LAION-5B metadata, the aesthetics score is estimated using an [improved aesthetics estimator](https://github.com/christophschuhmann/improved-aesthetic-predictor)). - `sd-v1-3.ckpt`: Resumed from `sd-v1-2.ckpt`. 195k steps at resolution `512x512` on "laion-improved-aesthetics" and 10\% dropping of the text-conditioning to improve [classifier-free guidance sampling](https://arxiv.org/abs/2207.12598). - **Hardware:** 32 x 8 x A100 GPUs - **Optimizer:** AdamW - **Gradient Accumulations**: 2 - **Batch:** 32 x 8 x 2 x 4 = 2048 - **Learning rate:** warmup to 0.0001 for 10,000 steps and then kept constant ## Evaluation Results Evaluations with different classifier-free guidance scales (1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0) and 50 PLMS sampling steps show the relative improvements of the checkpoints: ![pareto](assets/v1-variants-scores.jpg) Evaluated using 50 PLMS steps and 10000 random prompts from the COCO2017 validation set, evaluated at 512x512 resolution. Not optimized for FID scores. ## Environmental Impact **Stable Diffusion v1** **Estimated Emissions** Based on that information, we estimate the following CO2 emissions using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700). The hardware, runtime, cloud provider, and compute region were utilized to estimate the carbon impact. - **Hardware Type:** A100 PCIe 40GB - **Hours used:** 150000 - **Cloud Provider:** AWS - **Compute Region:** US-east - **Carbon Emitted (Power consumption x Time x Carbon produced based on location of power grid):** 11250 kg CO2 eq. ## Citation @InProceedings{Rombach_2022_CVPR, author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn}, title = {High-Resolution Image Synthesis With Latent Diffusion Models}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, month = {June}, year = {2022}, pages = {10684-10695} } *This model card was written by: Robin Rombach and Patrick Esser and is based on the [DALL-E Mini model card](https://huggingface.co/dalle-mini/dalle-mini).* ================================================ FILE: Web_based_UI_for_Stable_Diffusion_colab.ipynb ================================================ { "cells": [ { "cell_type": "markdown", "metadata": { "id": "S5RoIM-5IPZJ" }, "source": [ "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Sygil-Dev/sygil-webui/blob/main/Web_based_UI_for_Stable_Diffusion_colab.ipynb)" ] }, { "cell_type": "markdown", "metadata": { "id": "5-Bx4AsEoPU-" }, "source": [ "# README" ] }, { "cell_type": "markdown", "metadata": { "id": "z4kQYMPQn4d-" }, "source": [ "###
Web-based UI for Stable Diffusion
\n", "\n", "## Created by [Sygil-Dev](https://github.com/Sygil-Dev)\n", "\n", "## [Visit Sygil-Dev's Discord Server](https://discord.gg/gyXNe4NySY) [![Discord Server](https://user-images.githubusercontent.com/5977640/190528254-9b5b4423-47ee-4f24-b4f9-fd13fba37518.png)](https://discord.gg/gyXNe4NySY)\n", "\n", "## Installation instructions for:\n", "\n", "- **[Windows](https://sygil-dev.github.io/sygil-webui/docs/1.windows-installation.html)**\n", "- **[Linux](https://sygil-dev.github.io/sygil-webui/docs/2.linux-installation.html)**\n", "\n", "### Want to ask a question or request a feature?\n", "\n", "Come to our [Discord Server](https://discord.gg/gyXNe4NySY) or use [Discussions](https://github.com/Sygil-Dev/sygil-webui/discussions).\n", "\n", "## Documentation\n", "\n", "[Documentation is located here](https://sygil-dev.github.io/sygil-webui/)\n", "\n", "## Want to contribute?\n", "\n", "Check the [Contribution Guide](CONTRIBUTING.md)\n", "\n", "[Sygil-Dev](https://github.com/Sygil-Dev) main devs:\n", "\n", "* ![hlky's avatar](https://avatars.githubusercontent.com/u/106811348?s=40&v=4) [hlky](https://github.com/hlky)\n", "* ![ZeroCool940711's avatar](https://avatars.githubusercontent.com/u/5977640?s=40&v=4)[ZeroCool940711](https://github.com/ZeroCool940711)\n", "* ![codedealer's avatar](https://avatars.githubusercontent.com/u/4258136?s=40&v=4)[codedealer](https://github.com/codedealer)\n", "\n", "### Project Features:\n", "\n", "* Two great Web UI's to choose from: Streamlit or Gradio\n", "\n", "* No more manually typing parameters, now all you have to do is write your prompt and adjust sliders\n", "\n", "* Built-in image enhancers and upscalers, including GFPGAN and realESRGAN\n", "\n", "* Run additional upscaling models on CPU to save VRAM\n", "\n", "* Textual inversion 🔥: [info](https://textual-inversion.github.io/) - requires enabling, see [here](https://github.com/hlky/sd-enable-textual-inversion), script works as usual without it enabled\n", "\n", "* Advanced img2img editor with Mask and crop capabilities\n", "\n", "* Mask painting 🖌️: Powerful tool for re-generating only specific parts of an image you want to change (currently Gradio only)\n", "\n", "* More diffusion samplers 🔥🔥: A great collection of samplers to use, including:\n", " \n", " - `k_euler` (Default)\n", " - `k_lms`\n", " - `k_euler_a`\n", " - `k_dpm_2`\n", " - `k_dpm_2_a`\n", " - `k_heun`\n", " - `PLMS`\n", " - `DDIM`\n", "\n", "* Loopback ➿: Automatically feed the last generated sample back into img2img\n", "\n", "* Prompt Weighting 🏋️: Adjust the strength of different terms in your prompt\n", "\n", "* Selectable GPU usage with `--gpu `\n", "\n", "* Memory Monitoring 🔥: Shows VRAM usage and generation time after outputting\n", "\n", "* Word Seeds 🔥: Use words instead of seed numbers\n", "\n", "* CFG: Classifier free guidance scale, a feature for fine-tuning your output\n", "\n", "* Automatic Launcher: Activate conda and run Stable Diffusion with a single command\n", "\n", "* Lighter on VRAM: 512x512 Text2Image & Image2Image tested working on 4GB\n", "\n", "* Prompt validation: If your prompt is too long, you will get a warning in the text output field\n", "\n", "* Copy-paste generation parameters: A text output provides generation parameters in an easy to copy-paste form for easy sharing.\n", "\n", "* Correct seeds for batches: If you use a seed of 1000 to generate two batches of two images each, four generated images will have seeds: `1000, 1001, 1002, 1003`.\n", "\n", "* Prompt matrix: Separate multiple prompts using the `|` character, and the system will produce an image for every combination of them.\n", "\n", "* Loopback for Image2Image: A checkbox for img2img allowing to automatically feed output image as input for the next batch. Equivalent to saving output image, and replacing input image with it.\n", "\n", "# Stable Diffusion Web UI\n", "\n", "A fully-integrated and easy way to work with Stable Diffusion right from a browser window.\n", "\n", "## Streamlit\n", "\n", "![](https://github.com/aedhcarrick/sygil-webui/blob/patch-2/images/streamlit/streamlit-t2i.png?raw=1)\n", "\n", "**Features:**\n", "\n", "- Clean UI with an easy to use design, with support for widescreen displays.\n", "- Dynamic live preview of your generations\n", "- Easily customizable presets right from the WebUI (Coming Soon!)\n", "- An integrated gallery to show the generations for a prompt or session (Coming soon!)\n", "- Better optimization VRAM usage optimization, less errors for bigger generations.\n", "- Text2Video - Generate video clips from text prompts right from the WEb UI (WIP)\n", "- Concepts Library - Run custom embeddings others have made via textual inversion.\n", "- Actively being developed with new features being added and planned - Stay Tuned!\n", "- Streamlit is now the new primary UI for the project moving forward.\n", "- *Currently in active development and still missing some of the features present in the Gradio Interface.*\n", "\n", "Please see the [Streamlit Documentation](docs/4.streamlit-interface.md) to learn more.\n", "\n", "## Gradio\n", "\n", "![](https://github.com/aedhcarrick/sygil-webui/blob/patch-2/images/gradio/gradio-t2i.png?raw=1)\n", "\n", "**Features:**\n", "\n", "- Older UI design that is fully functional and feature complete.\n", "- Has access to all upscaling models, including LSDR.\n", "- Dynamic prompt entry automatically changes your generation settings based on `--params` in a prompt.\n", "- Includes quick and easy ways to send generations to Image2Image or the Image Lab for upscaling.\n", "- *Note, the Gradio interface is no longer being actively developed and is only receiving bug fixes.*\n", "\n", "Please see the [Gradio Documentation](docs/5.gradio-interface.md) to learn more.\n", "\n", "## Image Upscalers\n", "\n", "---\n", "\n", "### GFPGAN\n", "\n", "![](https://github.com/aedhcarrick/sygil-webui/blob/patch-2/images/GFPGAN.png?raw=1)\n", "\n", "Lets you improve faces in pictures using the GFPGAN model. There is a checkbox in every tab to use GFPGAN at 100%, and also a separate tab that just allows you to use GFPGAN on any picture, with a slider that controls how strong the effect is.\n", "\n", "If you want to use GFPGAN to improve generated faces, you need to install it separately.\n", "Download [GFPGANv1.4.pth](https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth) and put it\n", "into the `/sygil-webui/models/gfpgan` directory.\n", "\n", "### RealESRGAN\n", "\n", "![](https://github.com/aedhcarrick/sygil-webui/blob/patch-2/images/RealESRGAN.png?raw=1)\n", "\n", "Lets you double the resolution of generated images. There is a checkbox in every tab to use RealESRGAN, and you can choose between the regular upscaler and the anime version.\n", "There is also a separate tab for using RealESRGAN on any picture.\n", "\n", "Download [RealESRGAN_x4plus.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth) and [RealESRGAN_x4plus_anime_6B.pth](https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth).\n", "Put them into the `sygil-webui/models/realesrgan` directory.\n", "\n", "\n", "\n", "### LSDR\n", "\n", "Download **LDSR** [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename last.ckpt to model.ckpt and place both under `sygil-webui/models/ldsr/`\n", "\n", "### GoBig, and GoLatent *(Currently on the Gradio version Only)*\n", "\n", "More powerful upscalers that uses a seperate Latent Diffusion model to more cleanly upscale images.\n", "\n", "\n", "\n", "Please see the [Image Enhancers Documentation](docs/6.image_enhancers.md) to learn more.\n", "\n", "-----\n", "\n", "### *Original Information From The Stable Diffusion Repo*\n", "\n", "# Stable Diffusion\n", "\n", "*Stable Diffusion was made possible thanks to a collaboration with [Stability AI](https://stability.ai/) and [Runway](https://runwayml.com/) and builds upon our previous work:*\n", "\n", "[**High-Resolution Image Synthesis with Latent Diffusion Models**](https://ommer-lab.com/research/latent-diffusion-models/)
\n", "[Robin Rombach](https://github.com/rromb)\\*,\n", "[Andreas Blattmann](https://github.com/ablattmann)\\*,\n", "[Dominik Lorenz](https://github.com/qp-qp)\\,\n", "[Patrick Esser](https://github.com/pesser),\n", "[Björn Ommer](https://hci.iwr.uni-heidelberg.de/Staff/bommer)
\n", "\n", "**CVPR '22 Oral**\n", "\n", "which is available on [GitHub](https://github.com/CompVis/latent-diffusion). PDF at [arXiv](https://arxiv.org/abs/2112.10752). Please also visit our [Project page](https://ommer-lab.com/research/latent-diffusion-models/).\n", "\n", "[Stable Diffusion](#stable-diffusion-v1) is a latent text-to-image diffusion\n", "model.\n", "Thanks to a generous compute donation from [Stability AI](https://stability.ai/) and support from [LAION](https://laion.ai/), we were able to train a Latent Diffusion Model on 512x512 images from a subset of the [LAION-5B](https://laion.ai/blog/laion-5b/) database.\n", "Similar to Google's [Imagen](https://arxiv.org/abs/2205.11487),\n", "this model uses a frozen CLIP ViT-L/14 text encoder to condition the model on text prompts.\n", "With its 860M UNet and 123M text encoder, the model is relatively lightweight and runs on a GPU with at least 10GB VRAM.\n", "See [this section](#stable-diffusion-v1) below and the [model card](https://huggingface.co/CompVis/stable-diffusion).\n", "\n", "## Stable Diffusion v1\n", "\n", "Stable Diffusion v1 refers to a specific configuration of the model\n", "architecture that uses a downsampling-factor 8 autoencoder with an 860M UNet\n", "and CLIP ViT-L/14 text encoder for the diffusion model. The model was pretrained on 256x256 images and\n", "then finetuned on 512x512 images.\n", "\n", "*Note: Stable Diffusion v1 is a general text-to-image diffusion model and therefore mirrors biases and (mis-)conceptions that are present\n", "in its training data.\n", "Details on the training procedure and data, as well as the intended use of the model can be found in the corresponding [model card](https://huggingface.co/CompVis/stable-diffusion).\n", "\n", "## Comments\n", "\n", "- Our codebase for the diffusion models builds heavily on [OpenAI's ADM codebase](https://github.com/openai/guided-diffusion)\n", " and [https://github.com/lucidrains/denoising-diffusion-pytorch](https://github.com/lucidrains/denoising-diffusion-pytorch).\n", " Thanks for open-sourcing!\n", "\n", "- The implementation of the transformer encoder is from [x-transformers](https://github.com/lucidrains/x-transformers) by [lucidrains](https://github.com/lucidrains?tab=repositories).\n", "\n", "## BibTeX\n", "\n", "```\n", "@misc{rombach2021highresolution,\n", " title={High-Resolution Image Synthesis with Latent Diffusion Models},\n", " author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},\n", " year={2021},\n", " eprint={2112.10752},\n", " archivePrefix={arXiv},\n", " primaryClass={cs.CV}\n", "}\n", "\n", "```" ] }, { "cell_type": "markdown", "metadata": { "id": "iegma7yteERV" }, "source": [ "# Config options for Colab instance\n", "> Before running, make sure GPU backend is enabled. (Unless you plan on generating with Stable Horde)\n", ">> Runtime -> Change runtime type -> Hardware Accelerator -> GPU (Make sure to save)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "OXn96M9deVtF" }, "outputs": [], "source": [ "#@title { display-mode: \"form\" }\n", "#@markdown WebUI repo (and branch)\n", "repo_name = \"Sygil-Dev/sygil-webui\" #@param {type:\"string\"}\n", "repo_branch = \"dev\" #@param {type:\"string\"}\n", "\n", "#@markdown Mount Google Drive\n", "mount_google_drive = True #@param {type:\"boolean\"}\n", "save_outputs_to_drive = True #@param {type:\"boolean\"}\n", "#@markdown Folder in Google Drive to search for custom models\n", "MODEL_DIR = \"sygil-webui/models\" #@param {type:\"string\"}\n", "\n", "#@markdown Folder in Google Drive to look for custom config file (streamlit.yaml)\n", "CONFIG_DIR = \"sygil-webui\" #@param {type:\"string\"}\n", "\n", "#@markdown Enter auth token from Huggingface.co\n", "#@markdown >(required for downloading stable diffusion model.)\n", "HF_TOKEN = \"\" #@param {type:\"string\"}\n", "\n", "#@markdown Select which models to prefetch\n", "STABLE_DIFFUSION = True #@param {type:\"boolean\"}\n", "WAIFU_DIFFUSION = False #@param {type:\"boolean\"}\n", "TRINART_SD = False #@param {type:\"boolean\"}\n", "SD_WD_LD_TRINART_MERGED = False #@param {type:\"boolean\"}\n", "GFPGAN = True #@param {type:\"boolean\"}\n", "REALESRGAN = True #@param {type:\"boolean\"}\n", "LDSR = True #@param {type:\"boolean\"}\n", "BLIP_MODEL = False #@param {type:\"boolean\"}\n", "\n", "#@markdown Save models to Google Drive for faster loading in future (Be warned! Make sure you have enough space!)\n", "SAVE_MODELS = False #@param {type:\"boolean\"}" ] }, { "cell_type": "markdown", "metadata": { "id": "IZjJSr-WPNxB" }, "source": [ "# Setup\n", "\n", ">Runtime will crash when installing conda. This is normal as we are forcing a restart of the runtime from code.\n", "\n", ">Just hit \"Run All\" again. 😑" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "eq0-E5mjSpmP" }, "outputs": [], "source": [ "#@title Make sure we have access to GPU backend\n", "!nvidia-smi -L" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "cDu33xkdJ5mD" }, "outputs": [], "source": [ "#@title Install miniConda (mamba)\n", "!pip install condacolab\n", "import condacolab\n", "condacolab.install_from_url(\"https://github.com/conda-forge/miniforge/releases/download/4.14.0-0/Mambaforge-4.14.0-0-Linux-x86_64.sh\")\n", "\n", "import condacolab\n", "condacolab.check()\n", "# The runtime will crash here!!! Don't panic! We planned for this remember?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "pZHGf03Vp305" }, "outputs": [], "source": [ "#@title Clone webUI repo and download font\n", "import os\n", "REPO_URL = os.path.join('https://github.com', repo_name)\n", "PATH_TO_REPO = os.path.join('/content', repo_name.split('/')[1])\n", "!git clone {REPO_URL}\n", "%cd {PATH_TO_REPO}\n", "!git checkout {repo_branch}\n", "!git pull" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "dmN2igp5Yk3z" }, "outputs": [], "source": [ "#@title Install dependencies\n", "!mamba install cudatoolkit=11.3 git numpy=1.22.3 pip=20.3 python=3.8.5 pytorch=1.11.0 scikit-image=0.19.2 torchvision=0.12.0 -y\n", "!python --version\n", "!pip install -r requirements.txt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Nxaxfgo_F8Am" }, "outputs": [], "source": [ "#@title Install localtunnel to openGoogle's ports\n", "!npm install localtunnel" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "pcSWo9Zkzbsf" }, "outputs": [], "source": [ "#@title Mount Google Drive (if selected)\n", "if mount_google_drive:\n", " # Mount google drive to store outputs.\n", " from google.colab import drive\n", " drive.mount('/content/drive/', force_remount=True)\n", "\n", "if save_outputs_to_drive:\n", " # Make symlink to redirect downloads\n", " OUTPUT_PATH = os.path.join('/content/drive/MyDrive', repo_name.split('/')[1], 'outputs')\n", " os.makedirs(OUTPUT_PATH, exist_ok=True)\n", " os.symlink(OUTPUT_PATH, os.path.join(PATH_TO_REPO, 'outputs'), target_is_directory=True)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "vMdmh81J70yA" }, "outputs": [], "source": [ "#@title Pre-fetch models\n", "%cd {PATH_TO_REPO}\n", "# make list of models we want to download\n", "model_list = {\n", " 'stable_diffusion': f'{STABLE_DIFFUSION}',\n", " 'waifu_diffusion': f'{WAIFU_DIFFUSION}',\n", " 'trinart_stable_diffusion': f'{TRINART_SD}',\n", " 'sd_wd_ld_trinart_merged': f'{SD_WD_LD_TRINART_MERGED}',\n", " 'gfpgan': f'{GFPGAN}',\n", " 'realesrgan': f'{REALESRGAN}',\n", " 'ldsr': f'{LDSR}',\n", " 'blip_model': f'{BLIP_MODEL}'}\n", "download_list = {k for (k,v) in model_list.items() if v == 'True'}\n", "\n", "# get model info (file name, download link, save location)\n", "import yaml\n", "from pprint import pprint\n", "with open('configs/webui/webui_streamlit.yaml') as f:\n", " dataMap = yaml.safe_load(f)\n", "models = dataMap['model_manager']['models']\n", "existing_models = []\n", "\n", "# copy script from model manager\n", "import requests, time, shutil\n", "from requests.auth import HTTPBasicAuth\n", "\n", "if MODEL_DIR != \"\":\n", " MODEL_DIR = os.path.join('/content/drive/MyDrive', MODEL_DIR)\n", "else:\n", " MODEL_DIR = '/content/drive/MyDrive'\n", "\n", "def download_file(file_name, file_path, file_url):\n", " os.makedirs(file_path, exist_ok=True)\n", " link_path = os.path.join(MODEL_DIR, file_name)\n", " full_path = os.path.join(file_path, file_name)\n", " if os.path.exists(link_path):\n", " print( file_name + \" found in Google Drive\")\n", " if not os.path.exists(full_path):\n", " print( \" creating symlink...\")\n", " os.symlink(link_path, full_path)\n", " else:\n", " print( \" symlink already exists\")\n", " elif not os.path.exists(full_path):\n", " print( \"Downloading \" + file_name + \"...\", end=\"\" )\n", " token = None\n", " if \"huggingface.co\" in file_url:\n", " token = HTTPBasicAuth('token', HF_TOKEN)\n", " try:\n", " with requests.get(file_url, auth = token, stream=True) as r:\n", " starttime = time.time()\n", " r.raise_for_status()\n", " with open(full_path, 'wb') as f:\n", " for chunk in r.iter_content(chunk_size=8192):\n", " f.write(chunk)\n", " if ((time.time() - starttime) % 60.0) > 2 :\n", " starttime = time.time()\n", " print( \".\", end=\"\" )\n", " print( \"done\" )\n", " print( \" \" + file_name + \" downloaded to \\'\" + file_path + \"\\'\" )\n", " if SAVE_MODELS and os.path.exists(MODEL_DIR):\n", " shutil.copy2(full_path,MODEL_DIR)\n", " print( \" Saved \" + file_name + \" to \" + MODEL_DIR)\n", " except:\n", " print( \"Failed to download \" + file_name + \".\" )\n", " return\n", " else:\n", " print( full_path + \" already exists.\" )\n", " existing_models.append(file_name)\n", "\n", "# download models in list\n", "for model in download_list:\n", " model_name = models[model]['model_name']\n", " file_info = models[model]['files']\n", " for file in file_info:\n", " file_name = file_info[file]['file_name']\n", " file_url = file_info[file]['download_link']\n", " if 'save_location' in file_info[file]:\n", " file_path = file_info[file]['save_location']\n", " else:\n", " file_path = models[model]['save_location']\n", " download_file(file_name, file_path, file_url)\n", "\n", "# add custom models not in list\n", "CUSTOM_MODEL_DIR = os.path.join(PATH_TO_REPO, 'models/custom')\n", "if os.path.exists(MODEL_DIR):\n", " custom_models = os.listdir(MODEL_DIR)\n", " custom_models = [m for m in custom_models if os.path.isfile(MODEL_DIR + '/' + m)]\n", " os.makedirs(CUSTOM_MODEL_DIR, exist_ok=True)\n", " print( \"Custom model(s) found: \" )\n", " for m in custom_models:\n", " if m in existing_models:\n", " continue\n", " full_path = os.path.join(CUSTOM_MODEL_DIR, m)\n", " if not os.path.exists(full_path):\n", " print( \" \" + m )\n", " os.symlink(os.path.join(MODEL_DIR , m), full_path)\n", "\n", "# get custom config file if it exists\n", "if CONFIG_DIR != \"\":\n", " CONFIG_FILE = os.path.join('/content/drive/MyDrive', CONFIG_DIR, 'userconfig_streamlit.yaml')\n", " config_location = os.path.join(PATH_TO_REPO, 'configs/webui/userconfig_streamlit.yaml')\n", " if os.path.exists(CONFIG_FILE) and not os.path.exists(config_location):\n", " os.symlink(CONFIG_DIR, config_location)\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "pjIjiCuJysJI" }, "source": [ "# Launch the web ui server\n", "### (optional) JS to prevent idle timeout:\n", "Press 'F12' OR ('CTRL' + 'SHIFT' + 'I') OR right click on this website -> inspect. Then click on the console tab and paste in the following code.\n", "```js,\n", "function ClickConnect(){\n", "console.log(\"Working\");\n", "document.querySelector(\"colab-toolbar-button#connect\").click()\n", "}\n", "setInterval(ClickConnect,60000)\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "-WknaU7uu_q6" }, "outputs": [], "source": [ "#@title Press play on the music player to keep the tab alive (Uses only 13MB of data)\n", "%%html\n", "Press play on the music player to keep the tab alive, then start your generation below (Uses only 13MB of data)
\n", "