Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved sampling #69

Merged
merged 8 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add new model specs
---------

Co-authored-by: Dominik Lorenz <53151171+qp-qp@users.noreply.github.com>
  • Loading branch information
jenuk and qp-qp committed Jul 26, 2023
commit 2d8361489e986fb5a93980c8fd9e5d50f11bf737
29 changes: 17 additions & 12 deletions scripts/demo/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
}

VERSION2SPECS = {
"SD-XL base": {
"SD-XL base (1.0)": {
"H": 1024,
"W": 1024,
"C": 4,
"f": 8,
"is_legacy": False,
"config": "configs/inference/sd_xl_base.yaml",
"ckpt": "checkpoints/sd_xl_base.safetensors",
"ckpt": "checkpoints/sd_xl_base_1.0.safetensors",
},
"SD-XL base (0.9)": {
"H": 1024,
Expand Down Expand Up @@ -79,7 +79,7 @@
"config": "configs/inference/sd_1_5.yaml",
"ckpt": "checkpoints/v1-5-pruned-emaonly.safetensors",
},
"SDXL-Refiner": {
"SDXL-Refiner (0.9)": {
"H": 1024,
"W": 1024,
"C": 4,
Expand All @@ -88,6 +88,16 @@
"config": "configs/inference/sd_xl_refiner.yaml",
"ckpt": "checkpoints/sd_xl_refiner_0.9.safetensors",
},
"SDXL-Refiner (1.0)": {
"H": 1024,
"W": 1024,
"C": 4,
"f": 8,
"is_legacy": True,
"config": "configs/inference/sd_xl_refiner.yaml",
"ckpt": "checkpoints/sd_xl_refiner_1.0.safetensors",
},

}


Expand Down Expand Up @@ -119,13 +129,12 @@ def run_txt2img(
stage2strength=None,
):
if version.startswith("SD-XL base"):
ratio = st.sidebar.selectbox("Ratio:", list(SD_XL_BASE_RATIOS.keys()), 10)
W, H = SD_XL_BASE_RATIOS[ratio]
W, H = st.selectbox("Resolution:", list(SD_XL_BASE_RATIOS.values()), 10)
else:
H = st.sidebar.number_input(
H = st.number_input(
"H", value=version_dict["H"], min_value=64, max_value=2048
)
W = st.sidebar.number_input(
W = st.number_input(
"W", value=version_dict["W"], min_value=64, max_value=2048
)
C = version_dict["C"]
Expand All @@ -143,9 +152,7 @@ def run_txt2img(
prompt=prompt,
negative_prompt=negative_prompt,
)

sampler, num_rows, num_cols = init_sampling(stage2strength=stage2strength)

num_samples = num_rows * num_cols

if st.button("Sample"):
Expand Down Expand Up @@ -192,7 +199,6 @@ def run_img2img(
strength = st.number_input(
"**Img2Img Strength**", value=0.5, min_value=0.0, max_value=1.0
)

sampler, num_rows, num_cols = init_sampling(
img2img_strength=strength,
stage2strength=stage2strength,
Expand Down Expand Up @@ -296,8 +302,7 @@ def apply_refiner(

if add_pipeline:
st.write("__________________________")

version2 = "SDXL-Refiner"
version2 = st.selectbox("Refiner:", ["SDXL-Refiner (0.9)", "SDXL-Refiner (1.0)"])
st.warning(
f"Running with {version2} as the second stage model. Make sure to provide (V)RAM :) "
)
Expand Down
1 change: 0 additions & 1 deletion scripts/demo/streamlit_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ def do_img2img(
force_uc_zero_embeddings=force_uc_zero_embeddings,
)
unload_model(model.conditioner)

for k in c:
c[k], uc[k] = map(lambda y: y[k][:num_samples].to("cuda"), (c, uc))

Expand Down