{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#FastDup - A tool for gaining insights from a large image collection\n\n#FastDup Software, (C) copyright 2022 Dr. Amir Alush and Dr. Danny Bickson.\n\n\"Large Image Datasets Today are a Mess | Blog Post | Video Tutorial\"\n\n\"FastDup is a tool for gaining insights from a large image collection. It can find anomalies, duplicate and near duplicate images, clusters of similarity, learn the normal behavior and temporal interactions between images. It can be used for smart subsampling of a higher quality dataset, outlier removal, novelty detection of new information to be sent for tagging. FastDup scales to millions of images running on CPU only.\"\n\nFrom the authors of GraphLab and Turi Create.\n\nhttps://github.com/visualdatabase/fastdup","metadata":{}},{"cell_type":"code","source":"!pip install -U fastdup","metadata":{"execution":{"iopub.status.busy":"2022-07-09T00:43:14.637772Z","iopub.execute_input":"2022-07-09T00:43:14.638231Z","iopub.status.idle":"2022-07-09T00:43:32.551365Z","shell.execute_reply.started":"2022-07-09T00:43:14.638141Z","shell.execute_reply":"2022-07-09T00:43:32.549518Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import fastdup\nfastdup.__version__","metadata":{"execution":{"iopub.status.busy":"2022-07-09T00:43:49.230263Z","iopub.execute_input":"2022-07-09T00:43:49.230658Z","iopub.status.idle":"2022-07-09T00:43:49.509763Z","shell.execute_reply.started":"2022-07-09T00:43:49.230625Z","shell.execute_reply":"2022-07-09T00:43:49.508484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/mayo-clinic-strip-ai","metadata":{"execution":{"iopub.status.busy":"2022-07-09T00:44:39.512773Z","iopub.execute_input":"2022-07-09T00:44:39.513164Z","iopub.status.idle":"2022-07-09T00:44:40.28704Z","shell.execute_reply.started":"2022-07-09T00:44:39.513132Z","shell.execute_reply":"2022-07-09T00:44:40.2858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#That's the only snippet that will take some time due to the images.","metadata":{}},{"cell_type":"code","source":"fastdup.run('/kaggle/input/mayo-clinic-strip-ai', work_dir='out')","metadata":{"execution":{"iopub.status.busy":"2022-07-09T00:45:18.388373Z","iopub.execute_input":"2022-07-09T00:45:18.388806Z","iopub.status.idle":"2022-07-09T01:25:20.52423Z","shell.execute_reply.started":"2022-07-09T00:45:18.388771Z","shell.execute_reply":"2022-07-09T01:25:20.520208Z"},"_kg_hide-output":false,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fastdup.create_duplicates_gallery('out/similarity.csv',save_path='.', num_images=20)","metadata":{"execution":{"iopub.status.busy":"2022-07-09T01:28:04.548154Z","iopub.execute_input":"2022-07-09T01:28:04.549235Z","iopub.status.idle":"2022-07-09T01:32:08.17351Z","shell.execute_reply.started":"2022-07-09T01:28:04.549189Z","shell.execute_reply":"2022-07-09T01:32:08.172329Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from IPython.display import HTML\nHTML('similarity.html')","metadata":{"execution":{"iopub.status.busy":"2022-07-09T01:32:25.977741Z","iopub.execute_input":"2022-07-09T01:32:25.978502Z","iopub.status.idle":"2022-07-09T01:32:26.011918Z","shell.execute_reply.started":"2022-07-09T01:32:25.978455Z","shell.execute_reply":"2022-07-09T01:32:26.010972Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fastdup.create_outliers_gallery('out/outliers.csv',save_path='.', num_images=20)","metadata":{"execution":{"iopub.status.busy":"2022-07-09T01:37:17.539985Z","iopub.execute_input":"2022-07-09T01:37:17.540474Z","iopub.status.idle":"2022-07-09T01:39:27.003607Z","shell.execute_reply.started":"2022-07-09T01:37:17.540441Z","shell.execute_reply":"2022-07-09T01:39:27.002433Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"HTML('outliers.html')","metadata":{"execution":{"iopub.status.busy":"2022-07-09T01:40:26.610529Z","iopub.execute_input":"2022-07-09T01:40:26.611706Z","iopub.status.idle":"2022-07-09T01:40:26.628526Z","shell.execute_reply.started":"2022-07-09T01:40:26.61165Z","shell.execute_reply":"2022-07-09T01:40:26.627196Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Unfortunately, the last snippet failed to read all images.","metadata":{}},{"cell_type":"code","source":"#fastdup.create_components_gallery('out','.')","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-07-09T01:47:06.097841Z","iopub.execute_input":"2022-07-09T01:47:06.098342Z","iopub.status.idle":"2022-07-09T01:47:06.103818Z","shell.execute_reply.started":"2022-07-09T01:47:06.098285Z","shell.execute_reply":"2022-07-09T01:47:06.102572Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"HTML('./components.html')","metadata":{"execution":{"iopub.status.busy":"2022-07-09T01:42:23.937286Z","iopub.execute_input":"2022-07-09T01:42:23.937682Z","iopub.status.idle":"2022-07-09T01:42:23.944874Z","shell.execute_reply.started":"2022-07-09T01:42:23.937652Z","shell.execute_reply":"2022-07-09T01:42:23.943695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Acknowledgements:\n\nFastDup Software, (C) copyright 2022 Dr. Amir Alush and Dr. Danny Bickson.\n\nFastDup https://github.com/visualdatabase/fastdup\n\nhttps://wordpress.org/plugins/fastdup/\n\n#Happy Cloning! Happy Kaggling! Prevent Strokes!","metadata":{}}]}