update samplers

This commit is contained in:
Vladimir Mandic
2023-05-30 12:18:22 -04:00
parent 24bbe045a7
commit b664991633
6 changed files with 33 additions and 9 deletions
+1 -2
View File
@@ -114,10 +114,9 @@ a{
cursor: pointer;
}
#txt2img_gallery img, #img2img_gallery img, #extras_gallery img{
#txt2img_gallery img, #img2img_gallery img, #extras_gallery img {
object-fit: scale-down;
width: -webkit-fill-available !important;
height: inherit !important;
}
#txt2img_actions_column, #img2img_actions_column {
gap: 0.5em;
+2
View File
@@ -176,6 +176,8 @@ class Api:
script_args[0] = 0
# get default values
if gr is None:
return script_args
with gr.Blocks(): # will throw errors calling ui function without this
for script in script_runner.scripts:
if script.ui(script.is_img2img):
+27 -2
View File
@@ -460,6 +460,7 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts, all_seeds, all_su
return f"{all_prompts[index]}{negative_prompt_text}\n{generation_params_text}".strip()
"""
def print_profile(profile, msg: str):
try:
from rich import print # pylint: disable=redefined-builtin
@@ -469,6 +470,24 @@ def print_profile(profile, msg: str):
lines = lines.split('\n')
lines = [l for l in lines if '/profiler' not in l]
print(f'Profile {msg}:', '\n'.join(lines))
"""
def print_profile(profile, msg: str):
import io
import pstats
try:
from rich import print # pylint: disable=redefined-builtin
except:
pass
profile.disable()
stream = io.StringIO()
ps = pstats.Stats(profile, stream=stream)
ps.sort_stats(pstats.SortKey.CUMULATIVE).print_stats(15)
profile = None
lines = stream.getvalue().split('\n')
lines = [l for l in lines if '<frozen' not in l and '{built-in' not in l and '/logging' not in l and '/rich' not in l]
print(f'Profile {msg}:', '\n'.join(lines))
def process_images(p: StableDiffusionProcessing) -> Processed:
@@ -490,12 +509,18 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
log.debug('Token merging applied')
if cmd_opts.profile:
"""
import torch.profiler # pylint: disable=redefined-outer-name
# activities=[torch.profiler.ProfilerActivity.CPU, torch.profiler.ProfilerActivity.CUDA]
with torch.profiler.profile(profile_memory=True, with_modules=True) as prof:
with torch.profiler.record_function("process_images"):
res = process_images_inner(p)
print_profile(prof, 'process_images')
"""
import cProfile
pr = cProfile.Profile()
pr.enable()
res = process_images_inner(p)
print_profile(pr, 'Torch')
else:
res = process_images_inner(p)
finally:
@@ -836,7 +861,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
if self.hr_upscaler is not None:
self.extra_generation_params["Hires upscaler"] = self.hr_upscaler
def sample(self, conditioning, unconditional_conditioning, seeds, subseeds, subseed_strength, prompts):
def sample(self, conditioning, unconditional_conditioning, seeds, subseeds, subseed_strength, prompts): # TODO this is majority of processing time
self.sampler = sd_samplers.create_sampler(self.sampler_name, self.sd_model)
latent_scale_mode = shared.latent_upscale_modes.get(self.hr_upscaler, None) if self.hr_upscaler is not None else shared.latent_upscale_modes.get(shared.latent_upscale_default_mode, "nearest")
if self.enable_hr and latent_scale_mode is None:
+1 -3
View File
@@ -10,9 +10,6 @@ from modules.script_callbacks import CFGDenoiserParams, cfg_denoiser_callback
from modules.script_callbacks import CFGDenoisedParams, cfg_denoised_callback
from modules.script_callbacks import AfterCFGCallbackParams, cfg_after_cfg_callback
# from tqdm.rich import trange
# k_diffusion.sampling.trange = trange
samplers_k_diffusion = [
('Euler a', 'sample_euler_ancestral', ['k_euler_a', 'k_euler_ancestral'], {}),
('Euler', 'sample_euler', ['k_euler'], {}),
@@ -31,6 +28,7 @@ samplers_k_diffusion = [
('DPM++ 2S a Karras', 'sample_dpmpp_2s_ancestral', ['k_dpmpp_2s_a_ka'], {'scheduler': 'karras'}),
('DPM++ 2M Karras', 'sample_dpmpp_2m', ['k_dpmpp_2m_ka'], {'scheduler': 'karras'}),
('DPM++ SDE Karras', 'sample_dpmpp_sde', ['k_dpmpp_sde_ka'], {'scheduler': 'karras'}),
('DPM++ 2M SDE', 'sample_dpmpp_2m_sde', ['k_dpmpp_2m_sde'], {}),
]
samplers_data_k_diffusion = [
+1 -1
View File
@@ -45,7 +45,7 @@ yapf
scikit-image
basicsr
compel
requests==2.30.0
requests==2.31.0
tqdm==4.65.0
accelerate==0.18.0
opencv-python==4.7.0.72