diff --git a/sahi/utils/coco.py b/sahi/utils/coco.py index 5db4e9ad0..4938cbaf7 100644 --- a/sahi/utils/coco.py +++ b/sahi/utils/coco.py @@ -1264,7 +1264,7 @@ def get_area_filtered_coco(self, min=0, max=float('inf'), intervals_per_category for image in self.images: is_valid_image = True for annotation in image.annotations: - if intervals_per_category is not None: + if intervals_per_category is not None and annotation.name in intervals_per_category.keys(): category_based_min = intervals_per_category[annotation.category_name]["min"] category_based_max = intervals_per_category[annotation.category_name]["max"] if (annotation.area < category_based_min