{"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":2965251,"sourceType":"datasetVersion","datasetId":1817999}],"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\nimport cv2\nimport os\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","execution":{"iopub.status.busy":"2023-11-30T18:23:06.272789Z","iopub.execute_input":"2023-11-30T18:23:06.273217Z","iopub.status.idle":"2023-11-30T18:23:07.052275Z","shell.execute_reply.started":"2023-11-30T18:23:06.273174Z","shell.execute_reply":"2023-11-30T18:23:07.050741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Loading","metadata":{}},{"cell_type":"code","source":"# No need to consider validation folder, we will work only with train and test\ntrain_path = \"/kaggle/input/vegetable-image-dataset/Vegetable Images/train\"\ntest_path = \"/kaggle/input/vegetable-image-dataset/Vegetable Images/test\"","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:23:09.429558Z","iopub.execute_input":"2023-11-30T18:23:09.430222Z","iopub.status.idle":"2023-11-30T18:23:09.436362Z","shell.execute_reply.started":"2023-11-30T18:23:09.430179Z","shell.execute_reply":"2023-11-30T18:23:09.435031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def data_load(path):\n    X = list()\n    y = list()\n    labels = 0\n    for dir_name,x,files in os.walk(path):\n        if(dir_name != path):\n            for file in files:\n                file_path = os.path.join(dir_name,file)\n                img = cv2.imread(file_path,flags=0)\n                img = cv2.resize(img,(32,32))\n                X.append(img.tolist())\n                y.append(labels)\n            labels = labels + 1\n    return X,y","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:25:48.537156Z","iopub.execute_input":"2023-11-30T18:25:48.537964Z","iopub.status.idle":"2023-11-30T18:25:48.547409Z","shell.execute_reply.started":"2023-11-30T18:25:48.537912Z","shell.execute_reply":"2023-11-30T18:25:48.545959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, y_train = data_load(train_path)","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:25:50.693746Z","iopub.execute_input":"2023-11-30T18:25:50.694187Z","iopub.status.idle":"2023-11-30T18:27:49.045833Z","shell.execute_reply.started":"2023-11-30T18:25:50.694152Z","shell.execute_reply":"2023-11-30T18:27:49.044581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train = np.array(X_train)\ny_train = np.array(y_train)","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:28:43.556162Z","iopub.execute_input":"2023-11-30T18:28:43.556615Z","iopub.status.idle":"2023-11-30T18:28:45.473421Z","shell.execute_reply.started":"2023-11-30T18:28:43.55658Z","shell.execute_reply":"2023-11-30T18:28:45.472116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train.shape","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:28:51.200337Z","iopub.execute_input":"2023-11-30T18:28:51.200801Z","iopub.status.idle":"2023-11-30T18:28:51.209496Z","shell.execute_reply.started":"2023-11-30T18:28:51.200767Z","shell.execute_reply":"2023-11-30T18:28:51.207941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.shape","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:28:53.843225Z","iopub.execute_input":"2023-11-30T18:28:53.843685Z","iopub.status.idle":"2023-11-30T18:28:53.849655Z","shell.execute_reply.started":"2023-11-30T18:28:53.843647Z","shell.execute_reply":"2023-11-30T18:28:53.848656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.unique(y_train)","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:29:38.846086Z","iopub.execute_input":"2023-11-30T18:29:38.846572Z","iopub.status.idle":"2023-11-30T18:29:38.856703Z","shell.execute_reply.started":"2023-11-30T18:29:38.846524Z","shell.execute_reply":"2023-11-30T18:29:38.85527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### visualize","metadata":{}},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:30:18.591581Z","iopub.execute_input":"2023-11-30T18:30:18.592898Z","iopub.status.idle":"2023-11-30T18:30:18.597222Z","shell.execute_reply.started":"2023-11-30T18:30:18.592855Z","shell.execute_reply":"2023-11-30T18:30:18.596352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(1,1))\nplt.imshow(X_train[1],cmap='gray')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-30T18:31:56.699336Z","iopub.execute_input":"2023-11-30T18:31:56.699842Z","iopub.status.idle":"2023-11-30T18:31:56.900782Z","shell.execute_reply.started":"2023-11-30T18:31:56.699797Z","shell.execute_reply":"2023-11-30T18:31:56.899226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test,y_test = data_load(test_path)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test.shape","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_test.shape","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## You have to start from here.......","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}