Skip to content

Commit f589d84

Browse files
authored
Fix stale batch state when looping set_image with generate_masks_by_points_patch (#495)
Reset images_batch, sources_batch, batch_state, and batch_results to None in set_image() so that generate_masks_by_points_patch() properly re-initializes batch state for the new image. Previously, calling set_image() in a loop left stale batch attributes from the prior iteration, causing dimension mismatch errors. Closes #494
1 parent 4c230a2 commit f589d84

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

samgeo/samgeo3.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ def set_image(
346346

347347
self.image_height, self.image_width = self.image.shape[:2]
348348

349+
# Reset batch processing attributes so that subsequent calls to
350+
# generate_masks_by_points_patch() re-initialize the batch state
351+
# for the new image instead of reusing stale state from a previous image.
352+
self.images_batch = None
353+
self.sources_batch = None
354+
self.batch_state = None
355+
self.batch_results = None
356+
349357
# Convert to PIL Image for processing
350358
image_for_processor = Image.fromarray(self.image)
351359

0 commit comments

Comments
 (0)