{"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":3649,"databundleVersionId":46718,"sourceType":"competition"}],"dockerImageVersionId":30587,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# CIFAR-10 Loading","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport os","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:24:49.568371Z","iopub.execute_input":"2023-11-30T15:24:49.569630Z","iopub.status.idle":"2023-11-30T15:24:49.602713Z","shell.execute_reply.started":"2023-11-30T15:24:49.569568Z","shell.execute_reply":"2023-11-30T15:24:49.601160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for dir_name,_,files in os.walk('/kaggle/input/cifar-10'):\n    for file in files:\n        print(file)","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:32:16.601348Z","iopub.execute_input":"2023-11-30T15:32:16.601766Z","iopub.status.idle":"2023-11-30T15:32:16.610618Z","shell.execute_reply.started":"2023-11-30T15:32:16.601735Z","shell.execute_reply":"2023-11-30T15:32:16.609383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install py7zr","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:34:33.734843Z","iopub.execute_input":"2023-11-30T15:34:33.735256Z","iopub.status.idle":"2023-11-30T15:34:51.628737Z","shell.execute_reply.started":"2023-11-30T15:34:33.735224Z","shell.execute_reply":"2023-11-30T15:34:51.627333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import py7zr","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:34:58.419017Z","iopub.execute_input":"2023-11-30T15:34:58.419519Z","iopub.status.idle":"2023-11-30T15:34:58.620475Z","shell.execute_reply.started":"2023-11-30T15:34:58.419478Z","shell.execute_reply":"2023-11-30T15:34:58.619015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with py7zr.SevenZipFile('/kaggle/input/cifar-10/train.7z','r') as fp:\n    fp.extract('/kaggle/working/')","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:37:57.910771Z","iopub.execute_input":"2023-11-30T15:37:57.911909Z","iopub.status.idle":"2023-11-30T15:39:03.183211Z","shell.execute_reply.started":"2023-11-30T15:37:57.911849Z","shell.execute_reply":"2023-11-30T15:39:03.181412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:43:13.906151Z","iopub.execute_input":"2023-11-30T15:43:13.906563Z","iopub.status.idle":"2023-11-30T15:43:14.215947Z","shell.execute_reply.started":"2023-11-30T15:43:13.906533Z","shell.execute_reply":"2023-11-30T15:43:14.214547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = list()\nfor dir_name,_,files in os.walk('/kaggle/working/train'):\n    for file in files:\n        path = os.path.join(dir_name,file)\n        img = cv2.imread(path)\n        images.append(img.tolist())","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:47:01.821689Z","iopub.execute_input":"2023-11-30T15:47:01.822263Z","iopub.status.idle":"2023-11-30T15:47:55.946782Z","shell.execute_reply.started":"2023-11-30T15:47:01.822218Z","shell.execute_reply":"2023-11-30T15:47:55.944533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images = np.array(images)","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:57:26.200782Z","iopub.execute_input":"2023-11-30T15:57:26.201566Z","iopub.status.idle":"2023-11-30T15:57:50.272404Z","shell.execute_reply.started":"2023-11-30T15:57:26.201226Z","shell.execute_reply":"2023-11-30T15:57:50.270233Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"images.shape","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:57:53.652323Z","iopub.execute_input":"2023-11-30T15:57:53.652839Z","iopub.status.idle":"2023-11-30T15:57:53.660775Z","shell.execute_reply.started":"2023-11-30T15:57:53.652802Z","shell.execute_reply":"2023-11-30T15:57:53.659524Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-11-30T16:00:24.583421Z","iopub.execute_input":"2023-11-30T16:00:24.583803Z","iopub.status.idle":"2023-11-30T16:00:24.590965Z","shell.execute_reply.started":"2023-11-30T16:00:24.583773Z","shell.execute_reply":"2023-11-30T16:00:24.589099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = images[0]","metadata":{"execution":{"iopub.status.busy":"2023-11-30T16:03:02.678174Z","iopub.execute_input":"2023-11-30T16:03:02.678602Z","iopub.status.idle":"2023-11-30T16:03:02.685481Z","shell.execute_reply.started":"2023-11-30T16:03:02.678572Z","shell.execute_reply":"2023-11-30T16:03:02.683239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img.shape","metadata":{"execution":{"iopub.status.busy":"2023-11-30T16:03:10.226569Z","iopub.execute_input":"2023-11-30T16:03:10.227025Z","iopub.status.idle":"2023-11-30T16:03:10.235979Z","shell.execute_reply.started":"2023-11-30T16:03:10.226990Z","shell.execute_reply":"2023-11-30T16:03:10.234937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(1,1))\nplt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-30T16:05:03.057665Z","iopub.execute_input":"2023-11-30T16:05:03.058371Z","iopub.status.idle":"2023-11-30T16:05:03.261932Z","shell.execute_reply.started":"2023-11-30T16:05:03.058309Z","shell.execute_reply":"2023-11-30T16:05:03.260496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(images[0])","metadata":{"execution":{"iopub.status.busy":"2023-11-30T15:58:19.357770Z","iopub.execute_input":"2023-11-30T15:58:19.358263Z","iopub.status.idle":"2023-11-30T15:58:19.369696Z","shell.execute_reply.started":"2023-11-30T15:58:19.358228Z","shell.execute_reply":"2023-11-30T15:58:19.367494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}