diff options
-rw-r--r-- | extensions-builtin/Lora/lora.py | 6 | ||||
-rw-r--r-- | modules/processing.py | 21 | ||||
-rw-r--r-- | scripts/outpainting_mk_2.py | 30 | ||||
-rwxr-xr-x | webui.sh | 17 |
4 files changed, 59 insertions, 15 deletions
diff --git a/extensions-builtin/Lora/lora.py b/extensions-builtin/Lora/lora.py index af93991c..34ff57dd 100644 --- a/extensions-builtin/Lora/lora.py +++ b/extensions-builtin/Lora/lora.py @@ -448,7 +448,11 @@ def list_available_loras(): continue
name = os.path.splitext(os.path.basename(filename))[0]
- entry = LoraOnDisk(name, filename)
+ try:
+ entry = LoraOnDisk(name, filename)
+ except OSError: # should catch FileNotFoundError and PermissionError etc.
+ errors.report(f"Failed to load LoRA {name} from {filename}", exc_info=True)
+ continue
available_loras[name] = entry
diff --git a/modules/processing.py b/modules/processing.py index 1169bd7f..b700a718 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -1156,7 +1156,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing): class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
sampler = None
- def __init__(self, init_images: list = None, resize_mode: int = 0, denoising_strength: float = 0.75, image_cfg_scale: float = None, mask: Any = None, mask_blur: int = 4, inpainting_fill: int = 0, inpaint_full_res: bool = True, inpaint_full_res_padding: int = 0, inpainting_mask_invert: int = 0, initial_noise_multiplier: float = None, **kwargs):
+ def __init__(self, init_images: list = None, resize_mode: int = 0, denoising_strength: float = 0.75, image_cfg_scale: float = None, mask: Any = None, mask_blur: int = None, mask_blur_x: int = 4, mask_blur_y: int = 4, inpainting_fill: int = 0, inpaint_full_res: bool = True, inpaint_full_res_padding: int = 0, inpainting_mask_invert: int = 0, initial_noise_multiplier: float = None, **kwargs):
super().__init__(**kwargs)
self.init_images = init_images
@@ -1167,7 +1167,11 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): self.image_mask = mask
self.latent_mask = None
self.mask_for_overlay = None
- self.mask_blur = mask_blur
+ if mask_blur is not None:
+ mask_blur_x = mask_blur
+ mask_blur_y = mask_blur
+ self.mask_blur_x = mask_blur_x
+ self.mask_blur_y = mask_blur_y
self.inpainting_fill = inpainting_fill
self.inpaint_full_res = inpaint_full_res
self.inpaint_full_res_padding = inpaint_full_res_padding
@@ -1189,8 +1193,17 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): if self.inpainting_mask_invert:
image_mask = ImageOps.invert(image_mask)
- if self.mask_blur > 0:
- image_mask = image_mask.filter(ImageFilter.GaussianBlur(self.mask_blur))
+ if self.mask_blur_x > 0:
+ np_mask = np.array(image_mask)
+ kernel_size = 2 * int(4 * self.mask_blur_x + 0.5) + 1
+ np_mask = cv2.GaussianBlur(np_mask, (kernel_size, 1), self.mask_blur_x)
+ image_mask = Image.fromarray(np_mask)
+
+ if self.mask_blur_y > 0:
+ np_mask = np.array(image_mask)
+ kernel_size = 2 * int(4 * self.mask_blur_y + 0.5) + 1
+ np_mask = cv2.GaussianBlur(np_mask, (1, kernel_size), self.mask_blur_y)
+ image_mask = Image.fromarray(np_mask)
if self.inpaint_full_res:
self.mask_for_overlay = image_mask
diff --git a/scripts/outpainting_mk_2.py b/scripts/outpainting_mk_2.py index 665dbe89..c98ab480 100644 --- a/scripts/outpainting_mk_2.py +++ b/scripts/outpainting_mk_2.py @@ -145,7 +145,6 @@ class Script(scripts.Script): process_width = p.width
process_height = p.height
- p.mask_blur = mask_blur*4
p.inpaint_full_res = False
p.inpainting_fill = 1
p.do_not_save_samples = True
@@ -156,6 +155,19 @@ class Script(scripts.Script): up = pixels if "up" in direction else 0
down = pixels if "down" in direction else 0
+ if left > 0 or right > 0:
+ mask_blur_x = mask_blur
+ else:
+ mask_blur_x = 0
+
+ if up > 0 or down > 0:
+ mask_blur_y = mask_blur
+ else:
+ mask_blur_y = 0
+
+ p.mask_blur_x = mask_blur_x*4
+ p.mask_blur_y = mask_blur_y*4
+
init_img = p.init_images[0]
target_w = math.ceil((init_img.width + left + right) / 64) * 64
target_h = math.ceil((init_img.height + up + down) / 64) * 64
@@ -191,10 +203,10 @@ class Script(scripts.Script): mask = Image.new("RGB", (process_res_w, process_res_h), "white")
draw = ImageDraw.Draw(mask)
draw.rectangle((
- expand_pixels + mask_blur if is_left else 0,
- expand_pixels + mask_blur if is_top else 0,
- mask.width - expand_pixels - mask_blur if is_right else res_w,
- mask.height - expand_pixels - mask_blur if is_bottom else res_h,
+ expand_pixels + mask_blur_x if is_left else 0,
+ expand_pixels + mask_blur_y if is_top else 0,
+ mask.width - expand_pixels - mask_blur_x if is_right else res_w,
+ mask.height - expand_pixels - mask_blur_y if is_bottom else res_h,
), fill="black")
np_image = (np.asarray(img) / 255.0).astype(np.float64)
@@ -224,10 +236,10 @@ class Script(scripts.Script): latent_mask = Image.new("RGB", (p.width, p.height), "white")
draw = ImageDraw.Draw(latent_mask)
draw.rectangle((
- expand_pixels + mask_blur * 2 if is_left else 0,
- expand_pixels + mask_blur * 2 if is_top else 0,
- mask.width - expand_pixels - mask_blur * 2 if is_right else res_w,
- mask.height - expand_pixels - mask_blur * 2 if is_bottom else res_h,
+ expand_pixels + mask_blur_x * 2 if is_left else 0,
+ expand_pixels + mask_blur_y * 2 if is_top else 0,
+ mask.width - expand_pixels - mask_blur_x * 2 if is_right else res_w,
+ mask.height - expand_pixels - mask_blur_y * 2 if is_bottom else res_h,
), fill="black")
p.latent_mask = latent_mask
@@ -114,7 +114,22 @@ fi # Check prerequisites gpu_info=$(lspci 2>/dev/null | grep -E "VGA|Display") case "$gpu_info" in - *"Navi 1"*|*"Navi 2"*) export HSA_OVERRIDE_GFX_VERSION=10.3.0 + *"Navi 1"*) + export HSA_OVERRIDE_GFX_VERSION=10.3.0 + if [[ -z "${TORCH_COMMAND}" ]] + then + pyv="$(${python_cmd} -c 'import sys; print(".".join(map(str, sys.version_info[0:2])))')" + if [[ $(bc <<< "$pyv <= 3.10") -eq 1 ]] + then + # Navi users will still use torch 1.13 because 2.0 does not seem to work. + export TORCH_COMMAND="pip install torch==1.13.1+rocm5.2 torchvision==0.14.1+rocm5.2 --index-url https://download.pytorch.org/whl/rocm5.2" + else + printf "\e[1m\e[31mERROR: RX 5000 series GPUs must be using at max python 3.10, aborting...\e[0m" + exit 1 + fi + fi + ;; + *"Navi 2"*) export HSA_OVERRIDE_GFX_VERSION=10.3.0 ;; *"Renoir"*) export HSA_OVERRIDE_GFX_VERSION=9.0.0 printf "\n%s\n" "${delimiter}" |