add more job state updates and update history tab

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-09-13 10:54:04 -04:00
parent 4e74172f3a
commit d351fdb98f
26 changed files with 69 additions and 77 deletions
+2
View File
@@ -51,6 +51,7 @@ def preprocess_image(
has_models:bool = False,
):
t0 = time.time()
jobid = shared.state.begin('Preprocess')
# run resize before
if p.resize_mode_before != 0 and p.resize_name_before != 'None':
@@ -246,4 +247,5 @@ def preprocess_image(
t1 = time.time()
process_timer.add('proc', t1-t0)
shared.state.end(jobid)
return processed_image, blended_image
+3
View File
@@ -160,6 +160,7 @@ class Processor():
self.load_config[k] = v
def load(self, processor_id: str = None, force: bool = True) -> str:
from modules.shared import state
try:
t0 = time.time()
processor_id = processor_id or self.processor_id
@@ -179,6 +180,7 @@ class Processor():
cls = config[processor_id]['class']
# log.debug(f'Control Processor loading: id="{processor_id}" class={cls.__name__}')
debug(f'Control Processor config={self.load_config}')
jobid = state.begin('Load processor')
if 'DWPose' in processor_id:
det_ckpt = 'https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_l_8x8_300e_coco/yolox_l_8x8_300e_coco_20211126_140236-d3bd2b23.pth'
if 'Tiny' == config['DWPose']['model']:
@@ -209,6 +211,7 @@ class Processor():
else:
self.model = cls() # class instance only
t1 = time.time()
state.end(jobid)
self.processor_id = processor_id
log.debug(f'Control Processor loaded: id="{processor_id}" class={self.model.__class__.__name__} time={t1-t0:.2f}')
return f'Processor loaded: {processor_id}'
+4 -5
View File
@@ -597,12 +597,9 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg
if processed_image is not None and isinstance(processed_image, Image.Image):
output_images.append(processed_image)
if is_generator:
if is_generator and frame is not None and video is not None:
image_txt = f'{output_image.width}x{output_image.height}' if output_image is not None else 'None'
if video is not None:
msg = f'Control output | {index} of {frames} skip {video_skip_frames} | Frame {image_txt}'
else:
msg = f'Control output | {index} of {len(inputs)} | Image {image_txt}'
msg = f'Control output | {index} of {frames} skip {video_skip_frames} | Frame {image_txt}'
yield (output_image, blended_image, msg) # result is control_output, proces_output
if video is not None and frame is not None:
@@ -643,5 +640,7 @@ def control_run(state: str = '', # pylint: disable=keyword-arg-before-vararg
if len(info_txt) > 0:
html_txt = html_txt + infotext_to_html(info_txt[0])
if is_generator:
jobid = shared.state.begin('UI')
yield (output_images, blended_image, html_txt, output_filename)
shared.state.end(jobid)
return (output_images, blended_image, html_txt, output_filename)
+3 -1
View File
@@ -4,7 +4,7 @@ import threading
from typing import Union
from diffusers import StableDiffusionPipeline, StableDiffusionXLPipeline, FluxPipeline, StableDiffusion3Pipeline, ControlNetModel
from modules.control.units import detect
from modules.shared import log, opts, cmd_opts, listdir
from modules.shared import log, opts, cmd_opts, state, listdir
from modules import errors, sd_models, devices, model_quant
from modules.processing import StableDiffusionProcessingControl
@@ -308,6 +308,7 @@ class ControlNet():
log.error(f'Control {what} model load: id="{model_id}" unknown base model')
return
self.reset()
jobid = state.begin(f'Load {what}')
if model_path.endswith('.safetensors'):
self.load_safetensors(model_id, model_path, cls, config)
else:
@@ -365,6 +366,7 @@ class ControlNet():
t1 = time.time()
self.model_id = model_id
log.info(f'Control {what} model loaded: id="{model_id}" path="{model_path}" cls={cls.__name__} time={t1-t0:.2f}')
state.end(jobid)
return f'{what} loaded model: {model_id}'
except Exception as e:
log.error(f'Control {what} model load: id="{model_id}" {e}')