{"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":"import numpy as np\nimport pandas as pd\nimport os\nimport cv2\nfrom tqdm import tqdm\ntqdm.pandas()","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-01T18:08:46.434924Z","iopub.execute_input":"2022-03-01T18:08:46.435719Z","iopub.status.idle":"2022-03-01T18:08:46.441570Z","shell.execute_reply.started":"2022-03-01T18:08:46.435682Z","shell.execute_reply":"2022-03-01T18:08:46.440685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = \"../input/happywhale-enhanced-dataset-light\"\n\ndef is_greyscale(folder):\n    def f(x):\n        image_path = os.path.join(path, folder, x)\n        image = cv2.imread(image_path)[:, :, ::-1]\n        return (image[:, :, 0] == image[:, :, 1]).all() and (image[:, :, 1] == image[:, :, 2]).all()\n    return f","metadata":{"execution":{"iopub.status.busy":"2022-03-01T18:08:46.443417Z","iopub.execute_input":"2022-03-01T18:08:46.444962Z","iopub.status.idle":"2022-03-01T18:08:46.462939Z","shell.execute_reply.started":"2022-03-01T18:08:46.444909Z","shell.execute_reply":"2022-03-01T18:08:46.461863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(os.path.join(path, \"train.csv\"))\ngreyscale_map = data[\"image\"].progress_map(is_greyscale(\"train_images\"))\nnp.save(\"train_grey_scale_mask.npy\", greyscale_map.values)","metadata":{"execution":{"iopub.status.busy":"2022-03-01T18:08:46.464482Z","iopub.execute_input":"2022-03-01T18:08:46.464821Z","iopub.status.idle":"2022-03-01T18:08:46.576513Z","shell.execute_reply.started":"2022-03-01T18:08:46.464774Z","shell.execute_reply":"2022-03-01T18:08:46.575912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(os.path.join(path, \"sample_submission.csv\"))\ngreyscale_map = data[\"inference_image\"].progress_map(is_greyscale(\"test_images\"))\nnp.save(\"test_grey_scale_mask.npy\", greyscale_map.values)","metadata":{"execution":{"iopub.status.busy":"2022-03-01T18:08:46.577927Z","iopub.execute_input":"2022-03-01T18:08:46.578634Z","iopub.status.idle":"2022-03-01T18:08:46.676564Z","shell.execute_reply.started":"2022-03-01T18:08:46.578583Z","shell.execute_reply":"2022-03-01T18:08:46.675328Z"},"trusted":true},"execution_count":null,"outputs":[]}]}