fix: Ensure that the visualisations happen on copies of the page image

Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com>
This commit is contained in:
Nikos Livathinos
2025-08-27 14:16:56 +02:00
parent 1435fc3b81
commit a9dcd43a7c
2 changed files with 3 additions and 3 deletions

View File

@@ -122,8 +122,8 @@ class LayoutModel(BasePageModel):
left_clusters = [c for c in clusters if c.label not in exclude_labels] left_clusters = [c for c in clusters if c.label not in exclude_labels]
right_clusters = [c for c in clusters if c.label in exclude_labels] right_clusters = [c for c in clusters if c.label in exclude_labels]
# Create a deep copy of the original image for both sides # Create a deep copy of the original image for both sides
left_image = copy.deepcopy(page.image) left_image = page.image.copy()
right_image = copy.deepcopy(page.image) right_image = page.image.copy()
# Draw clusters on both images # Draw clusters on both images
draw_clusters(left_image, left_clusters, scale_x, scale_y) draw_clusters(left_image, left_clusters, scale_x, scale_y)

View File

@@ -90,7 +90,7 @@ class PagePreprocessingModel(BasePageModel):
# DEBUG code: # DEBUG code:
def draw_text_boxes(image, cells, show: bool = False): def draw_text_boxes(image, cells, show: bool = False):
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image.copy())
for c in cells: for c in cells:
x0, y0, x1, y1 = ( x0, y0, x1, y1 = (
c.to_bounding_box().l, c.to_bounding_box().l,