{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":45867,"databundleVersionId":6924515,"sourceType":"competition"}],"dockerImageVersionId":30626,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!apt update -y\n!apt install -y libvips libvips-tools\n!pip install pyvips","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-12-14T23:56:10.042372Z","iopub.execute_input":"2023-12-14T23:56:10.042986Z","iopub.status.idle":"2023-12-14T23:56:54.275059Z","shell.execute_reply.started":"2023-12-14T23:56:10.042949Z","shell.execute_reply":"2023-12-14T23:56:54.273934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport gc\nimport cv2\nimport glob\nimport zipfile\nimport time\nimport threading\nimport pyvips\nimport random as rn\nfrom tqdm import tqdm\nfrom PIL import Image\n# from threading import Thread\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport tensorflow as tf\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:56:54.277059Z","iopub.execute_input":"2023-12-14T23:56:54.27741Z","iopub.status.idle":"2023-12-14T23:57:07.062341Z","shell.execute_reply.started":"2023-12-14T23:56:54.277376Z","shell.execute_reply":"2023-12-14T23:57:07.060771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fs = glob.glob(f'/kaggle/input/UBC-OCEAN/train_images/*.png')","metadata":{"execution":{"iopub.status.busy":"2023-12-14T23:58:20.723194Z","iopub.execute_input":"2023-12-14T23:58:20.723572Z","iopub.status.idle":"2023-12-14T23:58:20.97287Z","shell.execute_reply.started":"2023-12-14T23:58:20.72351Z","shell.execute_reply":"2023-12-14T23:58:20.971848Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i, f in tqdm(enumerate(fs)):\n    img = pyvips.Image.new_from_file(f).numpy()\n    del img\n    gc.collect()\n    if i % 1 == 0:\n        !du -sh /tmp","metadata":{"execution":{"iopub.status.busy":"2023-12-15T00:08:00.755153Z","iopub.execute_input":"2023-12-15T00:08:00.755631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}