diff --git a/src/transformers/models/detr/image_processing_detr.py b/src/transformers/models/detr/image_processing_detr.py index 76c4b378c9f8c4..e6b6433203d730 100644 --- a/src/transformers/models/detr/image_processing_detr.py +++ b/src/transformers/models/detr/image_processing_detr.py @@ -1897,8 +1897,8 @@ def post_process_instance_segmentation( instance_maps, segments = [], [] current_segment_id = 0 - for j in range(num_queries): - score = pred_scores[j].item() + for j, score in enumerate(pred_scores): + score = score.item() if not torch.all(pred_masks[j] == 0) and score >= threshold: segmentation[pred_masks[j] == 1] = current_segment_id