Merge pull request #1257 from ZeroCool940711/dev

The denoising_strength slider on img2img is now customizable using the config file.
This commit is contained in:
ZeroCool 2022-09-21 14:59:42 -07:00 committed by GitHub
commit 6808a87d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -464,8 +464,10 @@ def layout():
help="How many images are at once in a batch. It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it takes to finish \
generation as more images are generated at once.Default: 1")
st.session_state["denoising_strength"] = st.slider("Denoising Strength:", value=st.session_state['defaults'].img2img.denoising_strength,
min_value=0.01, max_value=1.0, step=0.01)
st.session_state["denoising_strength"] = st.slider("Denoising Strength:", value=st.session_state['defaults'].img2img.denoising_strength.value,
min_value=st.session_state['defaults'].img2img.denoising_strength.min_value,
max_value=st.session_state['defaults'].img2img.denoising_strength.max_value,
step=st.session_state['defaults'].img2img.denoising_strength.step)
with st.expander("Preview Settings"):
st.session_state["update_preview"] = st.checkbox("Update Image Preview", value=st.session_state['defaults'].img2img.update_preview,

View File

@ -1738,3 +1738,13 @@ def constrain_image(img, max_width, max_height):
resampler = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS)
resized = img.resize((int(img.width / ratio), int(img.height / ratio)), resample=resampler)
return resized
def convert_pt_to_bin_and_load(input_file, text_encoder, tokenizer, placeholder_token):
x = torch.load(input_file, map_location=torch.device('cpu'))
params_dict = {
placeholder_token: torch.tensor(list(x['string_to_param'].items())[0][1])
}
torch.save(params_dict, "learned_embeds.bin")
load_learned_embed_in_clip("learned_embeds.bin", text_encoder, tokenizer, placeholder_token)
print("loaded", placeholder_token)