Skip to content

Commit

Permalink
Make inpaint workflow compatible with requests from older plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
Acly committed Jul 7, 2024
1 parent 7377f86 commit 885c2b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions ai_diffusion/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ExtentInput:
class ImageInput:
extent: ExtentInput
initial_image: Image | None = None
initial_mask: Image | None = None # deprecated (1.20.0) - hires_mask is scaled during workflow
hires_image: Image | None = None
hires_mask: Image | None = None

Expand Down
10 changes: 8 additions & 2 deletions ai_diffusion/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,14 @@ def inpaint(
in_image = scale_to_initial(extent, w, in_image, models)
in_mask = w.load_mask(ensure(images.hires_mask))
in_mask = apply_grow_feather(w, in_mask, params)
initial_mask = scale_to_initial(extent, w, in_mask, models, is_mask=True)
cropped_mask = w.crop_mask(in_mask, target_bounds)
if images.initial_mask:
# Deprecated in 1.20.0 - initial_mask is no longer used
initial_mask = w.load_mask(images.initial_mask)
initial_mask = scale_to_initial(extent, w, initial_mask, models, is_mask=True)
cropped_mask = in_mask
else:
initial_mask = scale_to_initial(extent, w, in_mask, models, is_mask=True)
cropped_mask = w.crop_mask(in_mask, target_bounds)

cond_base = cond.copy()
cond_base.downscale(extent.input, extent.initial)
Expand Down

0 comments on commit 885c2b0

Please sign in to comment.