{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":112509,"databundleVersionId":14254895,"sourceType":"competition"}],"dockerImageVersionId":31192,"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\n\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":{"iopub.status.busy":"2025-12-09T17:48:50.214927Z","iopub.execute_input":"2025-12-09T17:48:50.215583Z","iopub.status.idle":"2025-12-09T17:48:50.577806Z","shell.execute_reply.started":"2025-12-09T17:48:50.215557Z","shell.execute_reply":"2025-12-09T17:48:50.57692Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"os._exit(0)\n","metadata":{"trusted":true,"execution":{"execution_failed":"2025-12-09T17:48:19.934Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"os.listdir(\"/kaggle/input/csiro-biomass/train\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:15.869246Z","iopub.execute_input":"2025-12-09T17:49:15.869715Z","iopub.status.idle":"2025-12-09T17:49:15.88079Z","shell.execute_reply.started":"2025-12-09T17:49:15.86969Z","shell.execute_reply":"2025-12-09T17:49:15.879874Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:21.372451Z","iopub.execute_input":"2025-12-09T17:49:21.372779Z","iopub.status.idle":"2025-12-09T17:49:21.377071Z","shell.execute_reply.started":"2025-12-09T17:49:21.372758Z","shell.execute_reply":"2025-12-09T17:49:21.376159Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/csiro-biomass/train.csv')\ndf_test = pd.read_csv('/kaggle/input/csiro-biomass/test.csv')\ndf_sub = pd.read_csv('/kaggle/input/csiro-biomass/sample_submission.csv')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:22.677391Z","iopub.execute_input":"2025-12-09T17:49:22.677671Z","iopub.status.idle":"2025-12-09T17:49:22.698839Z","shell.execute_reply.started":"2025-12-09T17:49:22.67765Z","shell.execute_reply":"2025-12-09T17:49:22.698008Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train.head(10)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:23.379383Z","iopub.execute_input":"2025-12-09T17:49:23.380044Z","iopub.status.idle":"2025-12-09T17:49:23.394249Z","shell.execute_reply.started":"2025-12-09T17:49:23.380017Z","shell.execute_reply":"2025-12-09T17:49:23.393457Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:25.348705Z","iopub.execute_input":"2025-12-09T17:49:25.349019Z","iopub.status.idle":"2025-12-09T17:49:25.35664Z","shell.execute_reply.started":"2025-12-09T17:49:25.348996Z","shell.execute_reply":"2025-12-09T17:49:25.355912Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_sub","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:27.216477Z","iopub.execute_input":"2025-12-09T17:49:27.217064Z","iopub.status.idle":"2025-12-09T17:49:27.225502Z","shell.execute_reply.started":"2025-12-09T17:49:27.217036Z","shell.execute_reply":"2025-12-09T17:49:27.2247Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dict1 = {\n    \n}\n\n\nfor i in range(0, len(df_train)):\n    image_name = df_train.iloc[i]['image_path']\n    if image_name in dict1:\n        dict1[image_name].append(df_train.iloc[i]['target'])\n    else:\n        dict1[image_name] = [df_train.iloc[i]['target']]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:28.223204Z","iopub.execute_input":"2025-12-09T17:49:28.223945Z","iopub.status.idle":"2025-12-09T17:49:28.374187Z","shell.execute_reply.started":"2025-12-09T17:49:28.22392Z","shell.execute_reply":"2025-12-09T17:49:28.373482Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dict1","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:30.910772Z","iopub.execute_input":"2025-12-09T17:49:30.911416Z","iopub.status.idle":"2025-12-09T17:49:30.936443Z","shell.execute_reply.started":"2025-12-09T17:49:30.911388Z","shell.execute_reply":"2025-12-09T17:49:30.935532Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.image as mpimg\nimport cv2\n\nX = []\ny = []\n\nfor i in dict1:\n    image_name = i\n    y.append(dict1[i])\n\n    image = mpimg.imread(f'/kaggle/input/csiro-biomass/{i}')\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n    image = cv2.resize(image, (300, 300))\n    image = image.reshape(300,300,1)\n    image = image / 255\n    X.append(image)\n\nimport numpy as np\n\n\n\nX = np.array(X)\ny = np.array(y)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:37.328931Z","iopub.execute_input":"2025-12-09T17:49:37.329666Z","iopub.status.idle":"2025-12-09T17:49:59.82329Z","shell.execute_reply.started":"2025-12-09T17:49:37.329633Z","shell.execute_reply":"2025-12-09T17:49:59.822491Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:59.824488Z","iopub.execute_input":"2025-12-09T17:49:59.824825Z","iopub.status.idle":"2025-12-09T17:49:59.830378Z","shell.execute_reply.started":"2025-12-09T17:49:59.824793Z","shell.execute_reply":"2025-12-09T17:49:59.829582Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"y.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:59.831227Z","iopub.execute_input":"2025-12-09T17:49:59.831483Z","iopub.status.idle":"2025-12-09T17:49:59.84376Z","shell.execute_reply.started":"2025-12-09T17:49:59.831455Z","shell.execute_reply":"2025-12-09T17:49:59.843155Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras import Sequential\nfrom keras.layers import Conv2D, MaxPooling2D ,Flatten ,Dense\nfrom keras.optimizers import Adam","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T17:49:59.845196Z","iopub.execute_input":"2025-12-09T17:49:59.845436Z","iopub.status.idle":"2025-12-09T17:50:04.981405Z","shell.execute_reply.started":"2025-12-09T17:49:59.84542Z","shell.execute_reply":"2025-12-09T17:50:04.980506Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential()\nmodel.add (Conv2D(filters= 128,kernel_size = (3 ,3), activation = 'relu' , input_shape = (300,300,1)))\nmodel.add (MaxPooling2D( pool_size = (2 ,2)))\nmodel.add (Conv2D(filters= 64,kernel_size = (3 ,3),activation = 'relu'))\nmodel.add (MaxPooling2D( pool_size = (2 ,2)))\nmodel.add (Flatten())\n\nmodel.add (Dense( units= 110,activation='relu'))\nmodel.add (Dense( units= 52,activation='relu' ))\nmodel.add (Dense( units= 16,activation='relu' ))\nmodel.add (Dense( units= 5,activation='linear' ))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:00:40.717257Z","iopub.execute_input":"2025-12-09T18:00:40.718071Z","iopub.status.idle":"2025-12-09T18:00:41.026596Z","shell.execute_reply.started":"2025-12-09T18:00:40.718032Z","shell.execute_reply":"2025-12-09T18:00:41.025773Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.compile(optimizer=Adam(learning_rate=0.001) , loss='mse' , metrics = ['mae'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:00:42.823136Z","iopub.execute_input":"2025-12-09T18:00:42.823754Z","iopub.status.idle":"2025-12-09T18:00:42.832594Z","shell.execute_reply.started":"2025-12-09T18:00:42.823727Z","shell.execute_reply":"2025-12-09T18:00:42.831837Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.fit(X,y, epochs= 10)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:00:45.723371Z","iopub.execute_input":"2025-12-09T18:00:45.723705Z","iopub.status.idle":"2025-12-09T18:13:18.807555Z","shell.execute_reply.started":"2025-12-09T18:00:45.723682Z","shell.execute_reply":"2025-12-09T18:13:18.80663Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_image = mpimg.imread('/kaggle/input/csiro-biomass/test/ID1001187975.jpg')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:14:13.140257Z","iopub.execute_input":"2025-12-09T18:14:13.140962Z","iopub.status.idle":"2025-12-09T18:14:13.314913Z","shell.execute_reply.started":"2025-12-09T18:14:13.140939Z","shell.execute_reply":"2025-12-09T18:14:13.314161Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_image.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:14:19.182552Z","iopub.execute_input":"2025-12-09T18:14:19.183407Z","iopub.status.idle":"2025-12-09T18:14:19.188318Z","shell.execute_reply.started":"2025-12-09T18:14:19.183365Z","shell.execute_reply":"2025-12-09T18:14:19.187613Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_image = cv2.cvtColor(test_image, cv2.COLOR_BGR2GRAY)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:14:45.380107Z","iopub.execute_input":"2025-12-09T18:14:45.38079Z","iopub.status.idle":"2025-12-09T18:14:45.386195Z","shell.execute_reply.started":"2025-12-09T18:14:45.380768Z","shell.execute_reply":"2025-12-09T18:14:45.385263Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_image = cv2.resize(test_image, (300, 300))\ntest_image = test_image.reshape(1, 300, 300, 1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:15:10.312046Z","iopub.execute_input":"2025-12-09T18:15:10.312365Z","iopub.status.idle":"2025-12-09T18:15:10.317811Z","shell.execute_reply.started":"2025-12-09T18:15:10.312344Z","shell.execute_reply":"2025-12-09T18:15:10.316848Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.predict(test_image)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-09T18:15:18.564156Z","iopub.execute_input":"2025-12-09T18:15:18.564425Z","iopub.status.idle":"2025-12-09T18:15:18.764042Z","shell.execute_reply.started":"2025-12-09T18:15:18.564407Z","shell.execute_reply":"2025-12-09T18:15:18.763335Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}