Skip to content

Commit dc7dbc4

Browse files
committed
Use computed region bounds for segmentation control
1 parent 9fa5755 commit dc7dbc4

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

ai_diffusion/model/control.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ def to_api(self, bounds: Bounds | None = None, time: int | None = None):
158158
return ControlInput(self.mode, image, strength, (self.start, self.end))
159159

160160
def generate_segmentation(self):
161-
if self.mode is not ControlMode.segmentation:
162-
return
161+
assert self.mode is ControlMode.segmentation
163162

164163
ok, msg = self._model.document.check_color_mode()
165164
if not ok and msg:
@@ -191,8 +190,7 @@ def _segmentation_image_from_regions(self, bounds: Bounds):
191190
layer
192191
for layer in root.layers.all
193192
if root.find_linked(layer, RegionLink.direct) is not None
194-
and layer.compute_bounds().area > 0
195-
and Bounds.intersection(bounds, layer.bounds).area > 0
193+
and Bounds.intersection(bounds, layer.compute_bounds()).area > 0
196194
]
197195

198196
for index, layer in enumerate(layers):

0 commit comments

Comments
 (0)