Skip to content

Commit ffd25eb

Browse files
committed
Found some more places where padding was applied to custom workflow selection masks #2411
1 parent 3c115e8 commit ffd25eb

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

ai_diffusion/custom_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def prepare_mask(
617617
case InpaintContext.automatic:
618618
bounds = Bounds.pad(mask.bounds, pad)
619619
case InpaintContext.mask_bounds:
620-
bounds = Bounds.pad(mask_bounds, pad)
620+
bounds = Bounds.pad(mask_bounds, pad, multiple=1)
621621
case other:
622622
raise ValueError(f"Invalid inpaint context: {other}")
623623
bounds = Bounds.clamp(bounds, canvas_bounds.extent)

ai_diffusion/model.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,9 @@ def _update_target_image(self):
15501550
def get_selection_modifiers(
15511551
arch: Arch | InpaintContext, inpaint_mode: InpaintMode, strength: float, min_size=256
15521552
):
1553+
if arch is InpaintContext.mask_bounds: # use exact bounds, no padding
1554+
return SelectionModifiers(multiple=1)
1555+
15531556
feather = settings.selection_feather / 100
15541557
invert = False
15551558

@@ -1559,19 +1562,13 @@ def get_selection_modifiers(
15591562
feather = min(feather, 0.01)
15601563
invert = True
15611564

1562-
if arch is InpaintContext.mask_bounds:
1563-
min_size = 0
1564-
multiple = 1
1565-
else:
1566-
multiple = resolution.diffusion_multiple
1567-
15681565
return SelectionModifiers(
15691566
feather_rel=feather * strength,
15701567
feather_min_px=round(settings.selection_min_transition * strength),
15711568
pad_rel=settings.selection_padding / 100,
15721569
pad_offset_px=settings.selection_grow_offset,
15731570
size_min_px=min_size,
1574-
multiple=multiple,
1571+
multiple=resolution.diffusion_multiple,
15751572
invert=invert,
15761573
)
15771574

0 commit comments

Comments
 (0)