mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
fix img2img/inpaint paste params
This commit is contained in:
@@ -19,6 +19,7 @@ Note: Release pending `diffusers==0.24`
|
||||
- better prompt display in process tab
|
||||
- increase maximum lora cache values
|
||||
- fix for python 3.9 compatibility
|
||||
- fix img2img/inpaint paste params
|
||||
|
||||
## Update for 2023-11-23
|
||||
|
||||
|
||||
@@ -208,7 +208,6 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s
|
||||
p.scale_by = scale_by
|
||||
p.scripts = modules.scripts.scripts_img2img
|
||||
p.script_args = args
|
||||
p.extra_generation_params['Resize mode'] = resize_mode
|
||||
if mask:
|
||||
p.extra_generation_params["Mask blur"] = mask_blur
|
||||
p.extra_generation_params["Mask alpha"] = mask_alpha
|
||||
|
||||
@@ -606,10 +606,14 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts=None, all_seeds=No
|
||||
args["Init image size"] = f"{getattr(p, 'init_img_width', 0)}x{getattr(p, 'init_img_height', 0)}"
|
||||
args["Init image hash"] = getattr(p, 'init_img_hash', None)
|
||||
args["Mask weight"] = getattr(p, "inpainting_mask_weight", shared.opts.inpainting_mask_weight) if p.is_using_inpainting_conditioning else None
|
||||
args['Resize mode'] = getattr(p, 'resize_mode', None)
|
||||
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)
|
||||
# lookup by index
|
||||
if getattr(p, 'resize_mode', None) is not None:
|
||||
RESIZE_MODES = ["None", "Resize fixed", "Crop and resize", "Resize and fill", "Latent upscale"]
|
||||
args['Resize mode'] = RESIZE_MODES[p.resize_mode]
|
||||
# TODO missing-by-index: inpainting_fill, inpaint_full_res, inpainting_mask_invert
|
||||
if 'face' in p.ops:
|
||||
args["Face restoration"] = shared.opts.face_restoration_model
|
||||
if 'color' in p.ops:
|
||||
|
||||
@@ -473,6 +473,9 @@ def load_model_weights(model: torch.nn.Module, checkpoint_info: CheckpointInfo,
|
||||
model.sd_model_hash = checkpoint_info.calculate_shorthash()
|
||||
model.sd_model_checkpoint = checkpoint_info.filename
|
||||
model.sd_checkpoint_info = checkpoint_info
|
||||
model.is_sdxl = False # a1111 compatibility item
|
||||
model.is_sd2 = False # a1111 compatibility item
|
||||
model.is_sd1 = True # a1111 compatibility item
|
||||
shared.opts.data["sd_checkpoint_hash"] = checkpoint_info.sha256
|
||||
model.logvar = model.logvar.to(devices.device) # fix for training
|
||||
sd_vae.delete_base_vae()
|
||||
@@ -549,10 +552,6 @@ class ModelData:
|
||||
with self.lock:
|
||||
try:
|
||||
self.sd_model = reload_model_weights(op='model')
|
||||
if self.sd_model is not None:
|
||||
self.sd_model.is_sdxl = False # a1111 compatibility item
|
||||
self.sd_model.is_sd2 = False # a1111 compatibility item
|
||||
self.sd_model.is_sd1 = True # a1111 compatibility item
|
||||
self.initial = False
|
||||
except Exception as e:
|
||||
shared.log.error("Failed to load stable diffusion model")
|
||||
@@ -1107,12 +1106,16 @@ def load_model(checkpoint_info=None, already_loaded_state_dict=None, timer=None,
|
||||
sd_model = None
|
||||
stdout = io.StringIO()
|
||||
with contextlib.redirect_stdout(stdout):
|
||||
"""
|
||||
try:
|
||||
clip_is_included_into_sd = sd1_clip_weight in state_dict or sd2_clip_weight in state_dict
|
||||
with sd_disable_initialization.DisableInitialization(disable_clip=clip_is_included_into_sd):
|
||||
sd_model = instantiate_from_config(sd_config.model)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
shared.log.error(f'LDM: instantiate from config: {e}')
|
||||
sd_model = instantiate_from_config(sd_config.model)
|
||||
"""
|
||||
sd_model = instantiate_from_config(sd_config.model)
|
||||
for line in stdout.getvalue().splitlines():
|
||||
if len(line) > 0:
|
||||
shared.log.info(f'LDM: {line.strip()}')
|
||||
|
||||
@@ -81,7 +81,7 @@ class DDPM(pl.LightningModule):
|
||||
super().__init__()
|
||||
assert parameterization in ["eps", "x0", "v"], 'currently only supporting "eps" and "x0" and "v"'
|
||||
self.parameterization = parameterization
|
||||
print(f"{self.__class__.__name__}: Running in {self.parameterization}-prediction mode")
|
||||
print(f"{self.__class__.__name__}: mode={self.parameterization}")
|
||||
self.cond_stage_model = None
|
||||
self.clip_denoised = clip_denoised
|
||||
self.log_every_t = log_every_t
|
||||
|
||||
@@ -301,8 +301,8 @@ class FrozenCLIPT5Encoder(AbstractEncoder):
|
||||
super().__init__()
|
||||
self.clip_encoder = FrozenCLIPEmbedder(clip_version, device, max_length=clip_max_length)
|
||||
self.t5_encoder = FrozenT5Embedder(t5_version, device, max_length=t5_max_length)
|
||||
print(f"{self.clip_encoder.__class__.__name__} has {count_params(self.clip_encoder) * 1.e-6:.2f} M parameters, "
|
||||
f"{self.t5_encoder.__class__.__name__} comes with {count_params(self.t5_encoder) * 1.e-6:.2f} M params.")
|
||||
print(f"{self.clip_encoder.__class__.__name__} params={count_params(self.clip_encoder) * 1.e-6:.2f} M "
|
||||
f"{self.t5_encoder.__class__.__name__} params={count_params(self.t5_encoder) * 1.e-6:.2f} M")
|
||||
|
||||
def encode(self, text):
|
||||
return self(text)
|
||||
|
||||
@@ -75,7 +75,7 @@ def mean_flat(tensor):
|
||||
def count_params(model, verbose=False):
|
||||
total_params = sum(p.numel() for p in model.parameters())
|
||||
if verbose:
|
||||
print(f"{model.__class__.__name__} has {total_params*1.e-6:.2f} M params.")
|
||||
print(f"{model.__class__.__name__} params={total_params*1.e-6:.2f}M")
|
||||
return total_params
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user