add infotext to control tab

This commit is contained in:
Vladimir Mandic
2024-05-13 09:34:58 -04:00
parent 74687dbc44
commit 5bc135630f
3 changed files with 20 additions and 15 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ button.custom-button { border-radius: var(--button-large-radius); padding: var(-
#control_results { margin: 0; padding: 0; }
#control_gallery { height: calc(100vw/3 + 60px); }
#txt2img_gallery, #img2img_gallery { height: 50vh; }
#control-result { padding: 0 0.2em 0 0.2em; background: var(--input-background-fill); line-height: 2em; white-space: pre-wrap; }
#control-result { background: var(--button-secondary-background-fill); padding: 0.2em; }
#control-inputs { margin-top: 1em; }
#txt2img_prompt_container, #img2img_prompt_container, #control_prompt_container { margin-right: var(--layout-gap) }
#txt2img_footer, #img2img_footer, #control_footer { height: fit-content; display: none; }
+18 -13
View File
@@ -14,6 +14,7 @@ from modules.control.units import t2iadapter # TencentARC T2I-Adapter
from modules.control.units import reference # ControlNet-Reference
from modules import devices, shared, errors, processing, images, sd_models, scripts, masking
from modules.processing_class import StableDiffusionProcessingControl
from modules.ui_common import infotext_to_html
from modules.api import script
@@ -207,9 +208,11 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
active_process.append(u.process)
shared.log.debug(f'Control process unit: i={num_units} process={u.process.processor_id}')
active_strength.append(float(u.strength))
p.ops.append('control')
debug(f'Control active: process={len(active_process)} model={len(active_model)}')
processed: processing.Processed = None
image_txt = ''
info_txt = []
has_models = False
selected_models: List[Union[controlnet.ControlNetModel, xs.ControlNetXSModel, t2iadapter.AdapterModel]] = None
control_conditioning = None
@@ -235,6 +238,7 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
debug(f'Control: run type={unit_type} models={has_models}')
if has_models:
p.ops.append('control')
p.extra_generation_params["Control mode"] = unit_type # overriden later with pretty-print
p.extra_generation_params["Control conditioning"] = control_conditioning if isinstance(control_conditioning, list) else [control_conditioning]
p.extra_generation_params['Control start'] = control_guidance_start if isinstance(control_guidance_start, list) else [control_guidance_start]
@@ -291,13 +295,6 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
p.strength = active_strength[0]
pipe = shared.sd_model
instance = None
"""
try:
pipe = diffusers.AutoPipelineForText2Image.from_pipe(shared.sd_model) # use set_diffuser_pipe
except Exception as e:
shared.log.warning(f'Control pipeline create: {e}')
pipe = shared.sd_model
"""
debug(f'Control pipeline: class={pipe.__class__.__name__} args={vars(p)}')
@@ -570,7 +567,11 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
processed: processing.Processed = processing.process_images(p) # run actual pipeline
else:
script_run = True
output = processed.images if processed is not None else None
output = None
if processed is not None:
output = processed.images
info_txt = [processed.infotext(p, i) for i in range(len(output))]
# output = pipe(**vars(p)).images # alternative direct pipe exec call
else: # blend all processed images and return
output = [processed_image]
@@ -633,11 +634,15 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
output_filename = images.save_video(p, filename=None, images=output_images, video_type=video_type, duration=video_duration, loop=video_loop, pad=video_pad, interpolate=video_interpolate, sync=True)
image_txt = f'| Frames {len(output_images)} | Size {output_images[0].width}x{output_images[0].height}'
image_txt += f' | {util.dict2str(p.extra_generation_params)}'
restore_pipeline()
debug(f'Control ready: {image_txt}')
debug(f'Ready: {image_txt}')
html_txt = f'<p>Ready {image_txt}</p>'
if len(info_txt) > 0:
html_txt = html_txt + infotext_to_html(info_txt[0])
if is_generator:
yield (output_images, blended_image, f'Control ready {image_txt}', output_filename)
yield (output_images, blended_image, html_txt, output_filename)
else:
yield (output_images, blended_image, f'Control ready {image_txt}', output_filename)
yield (output_images, blended_image, html_txt, output_filename)
return
+1 -1
View File
@@ -324,7 +324,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
if self.image_mask is not None:
self.ops.append('inpaint')
else:
elif hasattr(self, 'init_images') and self.init_images is not None:
self.ops.append('img2img')
crop_region = None