From 80f29a25a7d2c945c769b41c0fd41e89cf7de31d Mon Sep 17 00:00:00 2001 From: amyeroberts <22614925+amyeroberts@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:00:57 +0100 Subject: [PATCH] MaskFormer post_process_instance_segmentation bug fix convert out side of loop (#25497) Bug fix - convert out side of loop --- .../models/mask2former/image_processing_mask2former.py | 7 ++++--- .../models/maskformer/image_processing_maskformer.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/transformers/models/mask2former/image_processing_mask2former.py b/src/transformers/models/mask2former/image_processing_mask2former.py index 2c5b8cca1cd..b9359251925 100644 --- a/src/transformers/models/mask2former/image_processing_mask2former.py +++ b/src/transformers/models/mask2former/image_processing_mask2former.py @@ -1026,9 +1026,10 @@ class Mask2FormerImageProcessor(BaseImageProcessor): ) current_segment_id += 1 instance_maps.append(pred_masks[j]) - # Return segmentation map in run-length encoding (RLE) format - if return_coco_annotation: - segmentation = convert_segmentation_to_rle(segmentation) + + # Return segmentation map in run-length encoding (RLE) format + if return_coco_annotation: + segmentation = convert_segmentation_to_rle(segmentation) # Return a concatenated tensor of binary instance maps if return_binary_maps and len(instance_maps) != 0: diff --git a/src/transformers/models/maskformer/image_processing_maskformer.py b/src/transformers/models/maskformer/image_processing_maskformer.py index a151700f97d..b5880566748 100644 --- a/src/transformers/models/maskformer/image_processing_maskformer.py +++ b/src/transformers/models/maskformer/image_processing_maskformer.py @@ -1081,9 +1081,10 @@ class MaskFormerImageProcessor(BaseImageProcessor): ) current_segment_id += 1 instance_maps.append(pred_masks[j]) - # Return segmentation map in run-length encoding (RLE) format - if return_coco_annotation: - segmentation = convert_segmentation_to_rle(segmentation) + + # Return segmentation map in run-length encoding (RLE) format + if return_coco_annotation: + segmentation = convert_segmentation_to_rle(segmentation) # Return a concatenated tensor of binary instance maps if return_binary_maps and len(instance_maps) != 0: