{"cells":[{"metadata":{},"cell_type":"markdown","source":"# VERSION II\nThe coding part of this notebook was moved to this [github repo](https://github.com/JanMalinowski/image_inspector)."},{"metadata":{},"cell_type":"markdown","source":"# Motivation\nRecently I've been going through two great courses. First of them was Andrew Ng's [Structuring Machine Learning Projects](https://www.coursera.org/learn/machine-learning-projects). The second one was the famous FasAi's course [Practical Deep Learning for Coders v4](https://course.fast.ai/). \n\\\nAndrew Ng suggested a neat way of inspecting a dataset (more specifically misclassified images), while Jeremy Howard showed how such application can be created using ipywidgets."},{"metadata":{},"cell_type":"markdown","source":"# Details\nLet's say that we have 1000 missclassified images. We suspect our models' poor performance on these images may be caused by the images being:\n- blurry\n- too bright/dark\n\n\nKnowing what fraction of misclassified images falls into one of these categories may help us to improve the classifier e.g. by using appropriate augmentations, getting a more reliable dataset etc.\n\nHowever, inspecting 1000 images manually and writing it down in a spreadsheet would take too much time. Therefore, I decided to create a small package that will faciliate the whole process."},{"metadata":{"trusted":true},"cell_type":"code","source":"# Importing the package\n!pip install git+git://github.com/JanMalinowski/image_inspector.git","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# Importing the necessary libraries\nfrom image_inspector import ImageInspector","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Example use\n\nThe class ImageInspector could be used for e.g. inspecting images from one of Kaggle's latest competitions [SIIM-ISIC Melanoma Classification](https://www.kaggle.com/c/siim-isic-melanoma-classification). Let's say that we want to know what fraction of images misclassified images contained hair, microscope's aperture, graduation scale etc."},{"metadata":{"trusted":true},"cell_type":"code","source":"path = \"../input/siic-isic-224x224-images/train\"\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import random\nimport os","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"imgs = os.listdir(path)\n# Creating some fake misclassified images\nimgs = random.choices(imgs, k=20)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"ii = ImageInspector(path, ['Hair', 'Aperture', 'Scale'],imgs)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"**Note: the navigation button work only inside of a running notebook.**"},{"metadata":{"trusted":true},"cell_type":"code","source":"ii()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"At any point of the inspection we can get the reslts dataframe by calling ```ii.get_results()```. Then we can use it to calculate fraction of errors falling into each category."},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}