mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
@@ -311,24 +311,24 @@ def process_samples(p: StableDiffusionProcessing, samples):
|
||||
images.save_image(image_mask_composite, p.outpath_samples, "", p.seeds[i], p.prompts[i], shared.opts.samples_format, info=info, p=p, suffix="-mask-composite")
|
||||
if shared.opts.return_mask:
|
||||
out_infotexts.append(info)
|
||||
out_images.append(image_mask)
|
||||
out_images.append(image_mask)
|
||||
if shared.opts.return_mask_composite:
|
||||
out_infotexts.append(info)
|
||||
out_images.append(image_mask_composite)
|
||||
out_images.append(image_mask_composite)
|
||||
|
||||
if shared.opts.include_mask:
|
||||
if shared.opts.mask_apply_overlay and p.overlay_images is not None and len(p.overlay_images) > 0:
|
||||
p.image_mask = create_binary_mask(p.overlay_images[0])
|
||||
p.image_mask = ImageOps.invert(p.image_mask)
|
||||
out_infotexts.append(info)
|
||||
out_images.append(p.image_mask)
|
||||
out_images.append(p.image_mask)
|
||||
elif getattr(p, 'image_mask', None) is not None and isinstance(p.image_mask, Image.Image):
|
||||
if getattr(p, 'mask_for_detailer', None) is not None:
|
||||
out_infotexts.append(info)
|
||||
out_images.append(p.mask_for_detailer)
|
||||
out_images.append(p.mask_for_detailer)
|
||||
else:
|
||||
out_infotexts.append(info)
|
||||
out_images.append(p.image_mask)
|
||||
out_images.append(p.image_mask)
|
||||
|
||||
if p.selected_scale_tab_after == 1:
|
||||
p.width_after, p.height_after = int(image.width * p.scale_by_after), int(image.height * p.scale_by_after)
|
||||
@@ -340,7 +340,7 @@ def process_samples(p: StableDiffusionProcessing, samples):
|
||||
|
||||
image.info["parameters"] = info
|
||||
out_infotexts.append(info)
|
||||
out_images.append(image)
|
||||
out_images.append(image)
|
||||
return out_images, out_infotexts
|
||||
|
||||
|
||||
|
||||
@@ -63,10 +63,10 @@ def hijack_set_module_tensor_simple(
|
||||
old_value = getattr(module, tensor_name)
|
||||
with devices.inference_context():
|
||||
if tensor_name in module._buffers: # pylint: disable=protected-access
|
||||
module._buffers[tensor_name] = value.to(device, non_blocking=shared.opts.diffusers_offload_nonblocking) # pylint: disable=protected-access
|
||||
module._buffers[tensor_name] = value.to(device, non_blocking=False) # pylint: disable=protected-access
|
||||
elif value is not None or not devices.same_device(device, module._parameters[tensor_name].device): # pylint: disable=protected-access
|
||||
param_cls = type(module._parameters[tensor_name]) # pylint: disable=protected-access
|
||||
module._parameters[tensor_name] = param_cls(value, requires_grad=old_value.requires_grad).to(device, non_blocking=shared.opts.diffusers_offload_nonblocking) # pylint: disable=protected-access
|
||||
module._parameters[tensor_name] = param_cls(value, requires_grad=old_value.requires_grad).to(device, non_blocking=False) # pylint: disable=protected-access
|
||||
t1 = time.time()
|
||||
tensor_to_timer += (t1 - t0)
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ def move_module_to_cpu(module, op='unk'):
|
||||
errors.display(e, f'Offload: type=balanced op=apply module={getattr(module, "__name__", None)}')
|
||||
|
||||
|
||||
def apply_balanced_offload_to_module(module, checkpoint_name="", op="apply"):
|
||||
def apply_balanced_offload_to_module(module, op="apply"):
|
||||
module_name = getattr(module, "module_name", module.__class__.__name__)
|
||||
network_layer_name = getattr(module, "network_layer_name", None)
|
||||
device_map = getattr(module, "balanced_offload_device_map", None)
|
||||
@@ -381,7 +381,7 @@ def apply_balanced_offload(sd_model=None, exclude=[]):
|
||||
continue
|
||||
module.module_name = module_name
|
||||
module.offload_dir = os.path.join(shared.opts.accelerate_offload_path, checkpoint_name, module_name)
|
||||
apply_balanced_offload_to_module(module, checkpoint_name=checkpoint_name)
|
||||
apply_balanced_offload_to_module(module, op='apply')
|
||||
set_accelerate(sd_model)
|
||||
t = time.time() - t0
|
||||
process_timer.add('offload', t)
|
||||
|
||||
@@ -276,10 +276,10 @@ def create_ui():
|
||||
shutdown_submit.click(fn=lambda: shared.restart_server(restart=False), _js="restartReload")
|
||||
|
||||
|
||||
def reset_quicksettings(components):
|
||||
components = components.split(',')
|
||||
def reset_quicksettings(quick_components):
|
||||
quick_components = quick_components.split(',')
|
||||
updates = []
|
||||
for key in components:
|
||||
for key in quick_components:
|
||||
shared.log.warning(f'Reset: setting={key}')
|
||||
updates.append(gr.update(value=shared.opts.get_default(key)))
|
||||
return updates
|
||||
|
||||
Reference in New Issue
Block a user