Repository: deepchecks/deepchecks

Issue:
[BUG] [Vision] Problem in label mapping for Coco dataset
**Describe the bug**
When displaying images from coco the label on the bounding boxes seems wrong.
The problem can either in the mapping itself or in the way in which we read the images and bboxes from files.

**To Reproduce**
See in our docs in - NewLabels check or read an image from the following: 
from deepchecks.vision.datasets.detection import coco

Proof - label 24 in the mapping represent a zebra
![Screen Shot 2022-05-02 at 15 13 22](https://user-images.githubusercontent.com/67195469/166231772-454112fe-1881-4904-8d73-d1905cc1cf3b.png)



Discussion:

Resolving patch:
diff --git a/deepchecks/vision/datasets/detection/coco.py b/deepchecks/vision/datasets/detection/coco.py
--- a/deepchecks/vision/datasets/detection/coco.py
+++ b/deepchecks/vision/datasets/detection/coco.py
@@ -348,95 +348,84 @@ def yolo_image_formatter(batch):
 
 
 LABEL_MAP = {
-    0: 'unknown',
-    1: 'person',
-    2: 'bicycle',
-    3: 'car',
-    4: 'motorcycle',
-    5: 'airplane',
-    6: 'bus',
-    7: 'train',
-    8: 'truck',
-    9: 'boat',
-    10: 'traffic light',
-    11: 'fire hydrant',
-    13: 'stop sign',
-    14: 'parking meter',
-    15: 'bench',
-    16: 'bird',
-    17: 'cat',
-    18: 'dog',
-    19: 'horse',
-    20: 'sheep',
-    21: 'cow',
-    22: 'elephant',
-    23: 'bear',
-    24: 'zebra',
-    25: 'giraffe',
-    26: 'hat',
-    27: 'backpack',
-    28: 'umbrella',
-    29: 'shoe',
-    30: 'eye glasses',
-    31: 'handbag',
-    32: 'tie',
-    33: 'suitcase',
-    34: 'frisbee',
-    35: 'skis',
-    36: 'snowboard',
-    37: 'sports ball',
-    38: 'kite',
-    39: 'baseball bat',
-    40: 'baseball glove',
-    41: 'skateboard',
-    42: 'surfboard',
-    43: 'tennis racket',
-    44: 'bottle',
-    45: 'plate',
-    46: 'wine glass',
-    47: 'cup',
-    48: 'fork',
-    49: 'knife',
-    50: 'spoon',
-    51: 'bowl',
-    52: 'banana',
-    53: 'apple',
-    54: 'sandwich',
-    55: 'orange',
-    56: 'broccoli',
-    57: 'carrot',
-    58: 'hot dog',
-    59: 'pizza',
-    60: 'donut',
-    61: 'cake',
-    62: 'chair',
-    63: 'couch',
-    64: 'potted plant',
-    65: 'bed',
-    66: 'mirror',
-    67: 'dining table',
-    68: 'window',
-    69: 'desk',
-    70: 'toilet',
-    71: 'door',
-    72: 'tv',
-    73: 'laptop',
-    74: 'mouse',
-    75: 'remote',
-    76: 'keyboard',
-    77: 'cell phone',
-    78: 'microwave',
-    79: 'oven',
-    80: 'toaster',
-    81: 'sink',
-    82: 'refrigerator',
-    83: 'blender',
-    84: 'book',
-    85: 'clock',
-    86: 'vase',
-    87: 'scissors',
-    88: 'teddy bear',
-    89: 'hair drier',
-    90: 'toothbrush',
-    91: 'hairbrush'
+    0: 'person',
+    1: 'bicycle',
+    2: 'car',
+    3: 'motorcycle',
+    4: 'airplane',
+    5: 'bus',
+    6: 'train',
+    7: 'truck',
+    8: 'boat',
+    9: 'traffic light',
+    10: 'fire hydrant',
+    11: 'stop sign',
+    12: 'parking meter',
+    13: 'bench',
+    14: 'bird',
+    15: 'cat',
+    16: 'dog',
+    17: 'horse',
+    18: 'sheep',
+    19: 'cow',
+    20: 'elephant',
+    21: 'bear',
+    22: 'zebra',
+    23: 'giraffe',
+    24: 'backpack',
+    25: 'umbrella',
+    26: 'handbag',
+    27: 'tie',
+    28: 'suitcase',
+    29: 'frisbee',
+    30: 'skis',
+    31: 'snowboard',
+    32: 'sports ball',
+    33: 'kite',
+    34: 'baseball bat',
+    35: 'baseball glove',
+    36: 'skateboard',
+    37: 'surfboard',
+    38: 'tennis racket',
+    39: 'bottle',
+    40: 'wine glass',
+    41: 'cup',
+    42: 'fork',
+    43: 'knife',
+    44: 'spoon',
+    45: 'bowl',
+    46: 'banana',
+    47: 'apple',
+    48: 'sandwich',
+    49: 'orange',
+    50: 'broccoli',
+    51: 'carrot',
+    52: 'hot dog',
+    53: 'pizza',
+    54: 'donut',
+    55: 'cake',
+    56: 'chair',
+    57: 'couch',
+    58: 'potted plant',
+    59: 'bed',
+    60: 'dining table',
+    61: 'toilet',
+    62: 'tv',
+    63: 'laptop',
+    64: 'mouse',
+    65: 'remote',
+    66: 'keyboard',
+    67: 'cell phone',
+    68: 'microwave',
+    69: 'oven',
+    70: 'toaster',
+    71: 'sink',
+    72: 'refrigerator',
+    73: 'book',
+    74: 'clock',
+    75: 'vase',
+    76: 'scissors',
+    77: 'teddy bear',
+    78: 'hair drier',
+    79: 'toothbrush'
 }
diff --git a/docs/source/checks/vision/distribution/plot_image_property_drift.py b/docs/source/checks/vision/distribution/plot_image_property_drift.py
--- a/docs/source/checks/vision/distribution/plot_image_property_drift.py
+++ b/docs/source/checks/vision/distribution/plot_image_property_drift.py
@@ -82,7 +82,7 @@
 # min_samples to 5 to tell the check to calculate drift despite having only a few images left after the class
 # filtration)
 
-check_result = ImagePropertyDrift(classes_to_display=['person', 'cat', 'cell phone', 'car'], min_samples=5
+check_result = ImagePropertyDrift(classes_to_display=['bicycle', 'bench', 'bus', 'truck'], min_samples=5
                                   ).run(train_dataset, test_dataset)
 check_result
 


Test patch:
diff --git a/tests/vision/checks/distribution/heatmap_comparison_test.py b/tests/vision/checks/distribution/heatmap_comparison_test.py
--- a/tests/vision/checks/distribution/heatmap_comparison_test.py
+++ b/tests/vision/checks/distribution/heatmap_comparison_test.py
@@ -61,19 +61,19 @@ def test_classification_limit_classes(mnist_dataset_train, mnist_dataset_test, d
 
 def test_object_detection_limit_classes(coco_train_visiondata, coco_test_visiondata, device):
     # Arrange
-    check = HeatmapComparison(classes_to_display=['person', 'cat'])
+    check = HeatmapComparison(classes_to_display=['bicycle', 'bench'])
 
     # Act
     result = check.run(coco_train_visiondata, coco_test_visiondata, device=device)
 
     # Assert
     brightness_diff = result.value["diff"]
-    assert_that(brightness_diff.mean(), close_to(49, 0.001))
-    assert_that(brightness_diff.max(), close_to(208, 0.001))
+    assert_that(brightness_diff.mean(), close_to(39.458, 0.001))
+    assert_that(brightness_diff.max(), close_to(170, 0.001))
 
     bbox_diff = result.value["diff_bbox"]
-    assert_that(bbox_diff.mean(), close_to(18.501, 0.001))
-    assert_that(bbox_diff.max(), close_to(100, 0.001))
+    assert_that(bbox_diff.mean(), close_to(15.154, 0.001))
+    assert_that(bbox_diff.max(), close_to(75, 0.001))
 
 
 def test_limit_classes_nonexistant_class(coco_train_visiondata, coco_test_visiondata, device):
diff --git a/tests/vision/checks/distribution/image_property_drift_test.py b/tests/vision/checks/distribution/image_property_drift_test.py
--- a/tests/vision/checks/distribution/image_property_drift_test.py
+++ b/tests/vision/checks/distribution/image_property_drift_test.py
@@ -37,14 +37,14 @@ def test_image_property_drift_check(coco_train_visiondata, coco_test_visiondata,
 
 def test_image_property_drift_check_limit_classes(coco_train_visiondata, coco_test_visiondata, device):
     # Run
-    result = ImagePropertyDrift(classes_to_display=['person', 'cat', 'cell phone', 'car'], min_samples=5
+    result = ImagePropertyDrift(classes_to_display=['bicycle', 'bench', 'bus', 'truck'], min_samples=5
                                 ).run(coco_train_visiondata, coco_test_visiondata, device=device)
 
     # Assert
     assert_that(result, is_correct_image_property_drift_result())
 
     assert_that(result.value, has_entries(
-        {'Brightness': close_to(0.15, 0.01)}
+        {'Brightness': close_to(0.103, 0.01)}
     ))
 
 
diff --git a/tests/vision/checks/distribution/new_labels_test.py b/tests/vision/checks/distribution/new_labels_test.py
--- a/tests/vision/checks/distribution/new_labels_test.py
+++ b/tests/vision/checks/distribution/new_labels_test.py
@@ -62,7 +62,7 @@ def test_object_detection_coco(coco_train_visiondata, coco_test_visiondata, devi
     result = NewLabels().run(coco_train_visiondata, coco_test_visiondata, device=device)
     # Assert
     assert_that(result.value, has_entries(
-        {'sandwich': close_to(14, 1), 'kite': close_to(7, 1), 'all_labels': close_to(387, 1)}
+        {'donut': close_to(14, 1), 'tennis racket': close_to(7, 1), 'all_labels': close_to(387, 1)}
     ))
 
 
@@ -72,10 +72,12 @@ def test_object_detection_coco_with_condition(coco_train_visiondata, coco_test_v
     result = check.conditions_decision(check.run(coco_train_visiondata, coco_test_visiondata, device=device))
     # Assert
     assert_that(result, has_items(
-        equal_condition_result(is_pass=False,
-                               name='Percentage of new labels in the test set not above 10%.',
-                               details='10.85% of labels found in test set were not in train set. '
-                                       'New labels most common in test set: [\'sandwich\', \'kite\', \'truck\']')
+        equal_condition_result(
+            is_pass=False,
+            name='Percentage of new labels in the test set not above 10%.',
+            details=(
+                '10.85% of labels found in test set were not in train set. '
+                'New labels most common in test set: [\'donut\', \'tennis racket\', \'boat\']'))
     ))
 
 
@@ -88,7 +90,7 @@ def test_object_detection_coco_new_labels(coco_train_visiondata, coco_test_visio
     result = NewLabels().run(coco_train_visiondata, test, device=device)
     # Assert
     assert_that(result.value, has_entries(
-        {'sandwich': close_to(14, 1), '-5': close_to(2, 1), 'all_labels': close_to(387, 1)}))
+        {'donut': close_to(14, 1), '-5': close_to(2, 1), 'all_labels': close_to(387, 1)}))
 
 
 def test_classification_mnist_with_condition(mnist_dataset_train, mnist_dataset_test, device):
diff --git a/tests/vision/checks/methodology/simple_feature_contribution_test.py b/tests/vision/checks/methodology/simple_feature_contribution_test.py
--- a/tests/vision/checks/methodology/simple_feature_contribution_test.py
+++ b/tests/vision/checks/methodology/simple_feature_contribution_test.py
@@ -187,9 +187,9 @@ def test_no_drift_object_detection_per_class(coco_train_visiondata):
 
     # Assert
     assert_that(result.value, has_entries({
-        'Brightness': has_entries({'train':  has_entries({'door': equal_to(0)}),
-                                   'test':  has_entries({'door': equal_to(0)}),
-                                   'train-test difference':  has_entries({'door': equal_to(0)})}),
+        'Brightness': has_entries({'train':  has_entries({'clock': equal_to(0)}),
+                                   'test':  has_entries({'clock': equal_to(0)}),
+                                   'train-test difference':  has_entries({'clock': equal_to(0)})}),
     }))
 
 
@@ -202,12 +202,12 @@ def test_drift_object_detection_per_class(coco_train_visiondata, coco_test_visio
 
     # Act
     result = check.run(train, test)
-
+    
     # Assert
     assert_that(result.value, has_entries({
-        'Brightness': has_entries({'train':  has_entries({'door': equal_to(0)}),
-                                   'test':  has_entries({'door': close_to(0.335, 0.01)}),
-                                   'train-test difference':  has_entries({'door': close_to(-0.335, 0.01)})}),
+        'Brightness': has_entries({'train':  has_entries({'fork': equal_to(0)}),
+                                   'test':  has_entries({'fork': close_to(0.0025, 0.001)}),
+                                   'train-test difference':  has_entries({'fork': close_to(-0.0025, 0.001)})}),
     }))
 
 
@@ -248,7 +248,11 @@ def test_train_test_condition_pps_train_fail(coco_train_visiondata, coco_test_vi
     assert_that(condition_result, equal_condition_result(
         is_pass=False,
         name=f'Train properties\' Predictive Power Score is not greater than {condition_value}',
-        details='Features in train dataset with PPS above threshold: {\'Mean Red Relative Intensity\': \'0.1\'}'
+        details=(
+            'Features in train dataset with PPS above threshold: '
+            '{\'Mean Red Relative Intensity\': \'0.11\', '
+            '\'Aspect Ratio\': \'0.09\'}'
+        )
     ))