make some params optional

This commit is contained in:
Vladimir Mandic
2023-12-18 11:46:08 -05:00
parent 327739d604
commit 21adfd57b7
5 changed files with 13 additions and 9 deletions
+1
View File
@@ -71,6 +71,7 @@ button.custom-button{ border-radius: var(--button-large-radius); padding: var(--
.performance p { display: inline-block; color: var(--body-text-color-subdued) !important }
.performance .time { margin-right: 0; }
#control_gallery { height: 564px; }
#control-result { padding: 0.5em; }
#control-inputs { margin-top: 1em; }
#txt2img_prompt_container, #img2img_prompt_container, #control_prompt_container { margin-right: var(--layout-gap) }
#txt2img_footer, #img2img_footer, #extras_footer, #control_footer { height: fit-content; display: none; }
+8 -5
View File
@@ -374,8 +374,8 @@ class Processed:
self.subseed_strength = p.subseed_strength
self.info = info
self.comments = comments
self.width = p.width
self.height = p.height
self.width = p.width if hasattr(p, 'width') else self.images[0].width
self.height = p.height if hasattr(p, 'height') else self.images[0].height
self.sampler_name = p.sampler_name
self.cfg_scale = p.cfg_scale
self.image_cfg_scale = p.image_cfg_scale
@@ -584,7 +584,7 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts=None, all_seeds=No
"Seed": all_seeds[index],
"Sampler": p.sampler_name,
"CFG scale": p.cfg_scale,
"Size": f"{p.width}x{p.height}",
"Size": f"{p.width}x{p.height}" if hasattr(p, 'width') and hasattr(p, 'height') else None,
"Batch": f'{p.n_iter}x{p.batch_size}' if p.n_iter > 1 or p.batch_size > 1 else None,
"Index": f'{p.iteration + 1}x{index + 1}' if (p.n_iter > 1 or p.batch_size > 1) and index >= 0 else None,
"Parser": shared.opts.prompt_attention,
@@ -636,6 +636,8 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts=None, all_seeds=No
args['Resize scale'] = getattr(p, 'scale_by', None)
args["Mask blur"] = p.mask_blur if getattr(p, 'mask', None) is not None and getattr(p, 'mask_blur', 0) > 0 else None
args["Denoising strength"] = getattr(p, 'denoising_strength', None)
if args["Size"] is None:
args["Size"] = args["Init image size"]
# lookup by index
if getattr(p, 'resize_mode', None) is not None:
args['Resize mode'] = shared.resize_modes[p.resize_mode]
@@ -1284,7 +1286,8 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
unprocessed = []
if getattr(self, 'init_images', None) is None:
return
# raise RuntimeError("No images provided")
if not isinstance(self.init_images, list):
self.init_images = [self.init_images]
for img in self.init_images:
if img is None:
shared.log.warning(f"Skipping empty image: images={self.init_images}")
@@ -1295,7 +1298,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
if shared.opts.save_init_img:
images.save_image(img, path=shared.opts.outdir_init_images, basename=None, forced_filename=self.init_img_hash, suffix="-init-image")
image = images.flatten(img, shared.opts.img2img_background_color)
if crop_region is None and self.resize_mode != 4:
if crop_region is None and self.resize_mode != 4 and self.resize_mode > 0:
if image.width != self.width or image.height != self.height:
image = images.resize_image(self.resize_mode, image, self.width, self.height, self.resize_name)
self.width = image.width
+2 -2
View File
@@ -527,7 +527,8 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro
update_sampler(shared.sd_model)
shared.state.sampling_steps = base_args['num_inference_steps']
p.extra_generation_params['Pipeline'] = shared.sd_model.__class__.__name__
p.extra_generation_params["Sampler Eta"] = shared.opts.scheduler_eta if shared.opts.scheduler_eta is not None and shared.opts.scheduler_eta > 0 and shared.opts.scheduler_eta < 1 else None
if shared.opts.scheduler_eta is not None and shared.opts.scheduler_eta > 0 and shared.opts.scheduler_eta < 1:
p.extra_generation_params["Sampler Eta"] = shared.opts.scheduler_eta
try:
t0 = time.time()
output = shared.sd_model(**base_args) # pylint: disable=not-callable
@@ -652,7 +653,6 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro
shared.state.sampling_steps = refiner_args['num_inference_steps']
try:
shared.sd_refiner.register_to_config(requires_aesthetics_score=shared.opts.diffusers_aesthetics_score)
print('HERE req', shared.sd_refiner.config.requires_aesthetics_score)
refiner_output = shared.sd_refiner(**refiner_args) # pylint: disable=not-callable
except AssertionError as e:
shared.log.info(e)
+1 -1
Submodule wiki updated: 8e60a3b8dc...554124a957