.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/vision/data_integrity/plot_image_property_outliers.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_checks_gallery_vision_data_integrity_plot_image_property_outliers.py: .. _plot_vision_image_property_outliers: Image Property Outliers ======================= This notebooks provides an overview for using and understanding the image property outliers check, used to detect outliers in simple image properties in a dataset. **Structure:** * `Why Check for Outliers? <#why-check-for-outliers>`__ * `How Does the Check Work? <#how-does-the-check-work>`__ * `Which Image Properties Are Used? <#which-image-properties-are-used>`__ * `Run the Check <#run-the-check>`__ Why Check for Outliers? ----------------------- Examining outliers may help you gain insights that you couldn't have reached from taking an aggregate look or by inspecting random samples. For example, it may help you understand you have some corrupt samples (e.g. an image that is completely black), or samples you didn't expect to have (e.g. extreme aspect ratio). In some cases, these outliers may help debug some performance discrepancies (the model can be excused for failing on a totally dark image). In more extreme cases, the outlier samples may indicate the presence of samples interfering with the model's training by teaching the model to fit "irrelevant" samples. How Does the Check Work? ------------------------ Ideally we would like to directly find images which are outliers, but this is computationally expensive and does not have a clear and explainable results. Therefore, we use image properties in order to find outliers (such as brightness, aspect ratio etc.) which are much more efficient to compute, and each outlier is easily explained. We use `Interquartile Range `_ to define our upper and lower limit for the properties' values. Which Image Properties Are Used? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default the checks use the built-in image properties, and it's also possible to replace the default properties with custom ones. For the list of the built-in image properties and explanation about custom properties refer to :doc:`vision properties `. .. GENERATED FROM PYTHON SOURCE LINES 48-51 Run the Check ------------- For the example we will load COCO object detection data, and will run the check with the default properties. .. GENERATED FROM PYTHON SOURCE LINES 51-60 .. code-block:: default from deepchecks.vision.checks import ImagePropertyOutliers from deepchecks.vision.datasets.detection.coco import load_dataset train_data = load_dataset(train=True, object_type='VisionData') check = ImagePropertyOutliers() result = check.run(train_data) result .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0/6984509 [00:00 Image Property Outliers

.. GENERATED FROM PYTHON SOURCE LINES 61-62 To display the results in an IDE like PyCharm, you can use the following code: .. GENERATED FROM PYTHON SOURCE LINES 62-64 .. code-block:: default # result.show_in_window() .. GENERATED FROM PYTHON SOURCE LINES 65-66 The result will be displayed in a new window. .. GENERATED FROM PYTHON SOURCE LINES 68-82 Observe Graphic Result ^^^^^^^^^^^^^^^^^^^^^^ The check shows a section for each property. In each section we show the number of outliers and the non-outlier property range, and also the images with the lowest and highest values for the property. For example in property "RMS Contrast" we can see that only 3 outliers were found, 1 below the normal property range and 2 above. Now we can inspect these images and decide if we wish to ignore these kinds of samples or if we would like the model to be able to support them, in which case we may take a close look into the model's predictions on these samples. Observe Result Value ^^^^^^^^^^^^^^^^^^^^ The check returns CheckResult object with a property 'value' on it which contain the information that was calculated in the check's run. .. GENERATED FROM PYTHON SOURCE LINES 82-84 .. code-block:: default result.value .. rst-class:: sphx-glr-script-out .. code-block:: none {'Aspect Ratio': {'indices': [6, 4, 27, 40, 63, 31, 8, 46, 10, 32, 22], 'lower_limit': 0.340625, 'upper_limit': 1.3029296874999998}, 'Area': {'indices': [60, 61, 44, 25, 62, 13, 6, 58, 50, 11, 26, 14, 45], 'lower_limit': 220800.0, 'upper_limit': 359040.0}, 'Brightness': {'indices': [54, 55, 47, 38, 62, 28], 'lower_limit': 0.23778584214186751, 'upper_limit': 0.6858694940161068}, 'RMS Contrast': {'indices': [54, 56, 61], 'lower_limit': 0.09993963741568856, 'upper_limit': 0.36929402509717535}, 'Mean Red Relative Intensity': {'indices': [50, 37, 36, 60, 61, 55], 'lower_limit': 0.24169391794555903, 'upper_limit': 0.4769510114694686}, 'Mean Green Relative Intensity': {'indices': [61, 3, 60, 63, 48, 54, 50], 'lower_limit': 0.28084770328411535, 'upper_limit': 0.4030514973864122}, 'Mean Blue Relative Intensity': {'indices': [60, 55, 50], 'lower_limit': 0.15795800862207085, 'upper_limit': 0.41322135317957304}} .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.578 seconds) .. _sphx_glr_download_checks_gallery_vision_data_integrity_plot_image_property_outliers.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_image_property_outliers.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_image_property_outliers.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_