Dev merge (#819)

* #715 #699 #698 #663 #625 #617 #611 #604 (#716)

* Update README.md

* Add sampler name to metadata (#695)

Co-authored-by: EliEron <example@example.com>

* old-dev-merge

Co-authored-by: EliEron <subanimehd@gmail.com>
Co-authored-by: EliEron <example@example.com>

* img2img-fix (#717)

* Revert "img2img-fix (#717)"

This reverts commit 70d4b1ca2a.

* img2img fixes

* Revert "img2img fixes"

This reverts commit e66eddc621.

* Revert "Revert "img2img-fix (#717)""

This reverts commit bf08b617d4.

* img2img fixed

* - Removed duplicated calls to save_sample.
- Change variables and arguments to be more self-explanatory and easier to understand what they do.

* Moved streamlit files to their proper location, before they were incorrectly added to the repository root folder.

* Added retry dependency for the streamlit version.

* Added .cmd file for easy running and updating the streamlit version of the UI.

* Removed duplicated entry for streamlit on the environment.yaml file.

* Removed some unnecessary lines from the the webui_streamlit.cmd file.

* add gfpgan folder to gitignore, auto gen by imglab

* added placeholder text similar to gradio

* added auto conversion for 4 channel PNG to RGB

* fix: regex escape characters

* Update Readme links to sd-webui when appropriate (#781)

* Update link to sd-webui when appropriate

* added LDSR instruction per devilismyfriend guide

* fix: stack overflow during recursion call (#784)

* Added option to set default sampler name from config file, will be useful for those wanting to change the default sampler and  have it persist even when closing the UI and opening it again.

* Added try and except block to handle basic errors like StopException which is raised by streamlit when you hit the stop button and KeyError which happens also when stopping the generation because it tries to check the model at the end which is not loaded at that time, this can be ignored and so thats the reason for the exception.

* separate css to external file

* Added "git pull" and "git stash" to the commands run by the cmd scripts when launching the UI, this should make it so people who use it can automatically update the code from the repo and be up to date without manually using those commands everytime.

* resolve conflict with master

Co-authored-by: EliEron <subanimehd@gmail.com>
Co-authored-by: EliEron <example@example.com>
Co-authored-by: ZeroCool <ZeroCool940711@users.noreply.github.com>
Co-authored-by: ZeroCool940711 <alejandrogilelias940711@gmail.com>
Co-authored-by: Hafiidz <3688500+Hafiidz@users.noreply.github.com>
Co-authored-by: Thomas Mello <work.mello@gmail.com>
This commit is contained in:
hlky 2022-09-08 11:41:04 +01:00 committed by GitHub
parent 688cb0d038
commit a00d827cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1932 additions and 2 deletions

1
.gitignore vendored
View File

@ -57,3 +57,4 @@ condaenv.*.requirements.txt
/log/**/*.png
/log/log.csv
/flagged/*
/gfpgan/*

View File

@ -0,0 +1,103 @@
# UI defaults configuration file. It is automatically loaded if located at configs/webui/webui_streamlit.yaml.
# Any changes made here will be available automatically on the web app without having to stop it.
general:
gpu: 0
outdir: outputs
ckpt: "models/ldm/stable-diffusion-v1/model.ckpt"
fp:
name: 'embeddings/alex/embeddings_gs-11000.pt'
GFPGAN_dir: "./src/gfpgan"
RealESRGAN_dir: "./src/realesrgan"
RealESRGAN_model: "RealESRGAN_x4plus"
outdir_txt2img: outputs/txt2img-samples
outdir_img2img: outputs/img2img-samples
gfpgan_cpu: False
esrgan_cpu: False
extra_models_cpu: False
extra_models_gpu: False
save_metadata: True
skip_grid: False
skip_save: False
grid_format: "jpg:95"
n_rows: -1
no_verify_input: False
no_half: False
precision: "autocast"
optimized: False
optimized_turbo: False
update_preview: True
update_preview_frequency: 1
txt2img:
prompt:
height: 512
width: 512
cfg_scale: 5.0
seed: ""
batch_count: 1
batch_size: 1
sampling_steps: 50
default_sampler: "k_lms"
separate_prompts: False
normalize_prompt_weights: True
save_individual_images: True
save_grid: True
group_by_prompt: True
save_as_jpg: False
use_GFPGAN: True
use_RealESRGAN: True
RealESRGAN_model: "RealESRGAN_x4plus"
variant_amount: 0.0
variant_seed: ""
img2img:
prompt:
sampling_steps: 50
# Adding an int to toggles enables the corresponding feature.
# 0: Create prompt matrix (separate multiple prompts using |, and get all combinations of them)
# 1: Normalize Prompt Weights (ensure sum of weights add up to 1.0)
# 2: Loopback (use images from previous batch when creating next batch)
# 3: Random loopback seed
# 4: Save individual images
# 5: Save grid
# 6: Sort samples by prompt
# 7: Write sample info files
# 8: jpg samples
# 9: Fix faces using GFPGAN
# 10: Upscale images using Real-ESRGAN
sampler_name: k_lms
denoising_strength: 0.45
# 0: Keep masked area
# 1: Regenerate only masked area
mask_mode: 0
# 0: Just resize
# 1: Crop and resize
# 2: Resize and fill
resize_mode: 0
# Leave blank for random seed:
seed: ""
ddim_eta: 0.0
cfg_scale: 5.0
batch_count: 1
batch_size: 1
height: 512
width: 512
# Textual inversion embeddings file path:
fp: ""
loopback: True
random_seed_loopback: True
separate_prompts: False
normalize_prompt_weights: True
save_individual_images: True
save_grid: True
group_by_prompt: True
save_as_jpg: False
use_GFPGAN: True
use_RealESRGAN: True
RealESRGAN_model: "RealESRGAN_x4plus"
variant_amount: 0.0
variant_seed: ""
gfpgan:
strength: 100

View File

@ -20,7 +20,6 @@ dependencies:
- pytorch-lightning==1.4.2
- omegaconf==2.1.1
- test-tube>=0.7.5
- streamlit>=0.73.1
- einops==0.3.0
- torch-fidelity==0.3.0
- transformers==4.19.2
@ -33,6 +32,7 @@ dependencies:
- facexlib>=0.2.3
- python-slugify>=6.1.2
- streamlit>=1.12.2
- retry>=0.9.2
- -e git+https://github.com/CompVis/taming-transformers#egg=taming-transformers
- -e git+https://github.com/openai/CLIP#egg=clip
- -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN

View File

@ -0,0 +1,15 @@
.css-18e3th9 {
padding-top: 2rem;
padding-bottom: 10rem;
padding-left: 5rem;
padding-right: 5rem;
}
.css-1d391kg {
padding-top: 3.5rem;
padding-right: 1rem;
padding-bottom: 3.5rem;
padding-left: 1rem;
}
button[data-baseweb="tab"] {
font-size: 25px;
}

View File

@ -98,7 +98,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, imgproc=lambda
choices=['RealESRGAN_x4plus',
'RealESRGAN_x4plus_anime_6B'],
value='RealESRGAN_x4plus',
visible=False) # RealESRGAN is not None # invisible until removed) # TODO: Feels like I shouldnt slot it in here.
visible=False) # RealESRGAN is not None # invisible until removed) # TODO: Feels like I shouldnt slot it in here.
txt2img_ddim_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="DDIM ETA",
value=txt2img_defaults['ddim_eta'], visible=False)
txt2img_variant_amount = gr.Slider(minimum=0.0, maximum=1.0, label='Variation Amount',

1754
scripts/webui_streamlit.py Normal file

File diff suppressed because it is too large Load Diff

53
webui-streamlit.cmd Normal file
View File

@ -0,0 +1,53 @@
@echo off
set conda_env_name=ldm
:: Put the path to conda directory after "=" sign if it's installed at non-standard path:
set custom_conda_path=
IF NOT "%custom_conda_path%"=="" (
set paths=%custom_conda_path%;%paths%
)
:: Put the path to conda directory in a file called "custom-conda-path.txt" if it's installed at non-standard path:
FOR /F %%i IN (custom-conda-path.txt) DO set custom_conda_path=%%i
set paths=%ProgramData%\miniconda3
set paths=%paths%;%USERPROFILE%\miniconda3
set paths=%paths%;%ProgramData%\anaconda3
set paths=%paths%;%USERPROFILE%\anaconda3
for %%a in (%paths%) do (
IF NOT "%custom_conda_path%"=="" (
set paths=%custom_conda_path%;%paths%
)
)
for %%a in (%paths%) do (
if EXIST "%%a\Scripts\activate.bat" (
SET CONDA_PATH=%%a
echo anaconda3/miniconda3 detected in %%a
goto :foundPath
)
)
IF "%CONDA_PATH%"=="" (
echo anaconda3/miniconda3 not found. Install from here https://docs.conda.io/en/latest/miniconda.html
exit /b 1
)
call git stash
call git pull
:foundPath
call "%CONDA_PATH%\Scripts\activate.bat"
call conda env create -n "%conda_env_name%" -f environment.yaml
call conda env update --name "%conda_env_name%" -f environment.yaml
call "%CONDA_PATH%\Scripts\activate.bat" "%conda_env_name%"
::python "%CD%"\scripts\relauncher.py
:PROMPT
set SETUPTOOLS_USE_DISTUTILS=stdlib
IF EXIST "models\ldm\stable-diffusion-v1\model.ckpt" (
python -m streamlit run scripts\webui_streamlit.py
) ELSE (
ECHO Your model file does not exist! Place it in 'models\ldm\stable-diffusion-v1' with the name 'model.ckpt'.
)

View File

@ -35,6 +35,9 @@ IF "%CONDA_PATH%"=="" (
exit /b 1
)
call git stash
call git pull
:foundPath
call "%CONDA_PATH%\Scripts\activate.bat"
call conda env create -n "%conda_env_name%" -f environment.yaml