{"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"},{"sourceId":13759219,"sourceType":"datasetVersion","datasetId":8744465},{"sourceId":13759497,"sourceType":"datasetVersion","datasetId":8743292}],"dockerImageVersionId":31192,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nos.listdir('/kaggle/working')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-11-17T02:24:11.822061Z","iopub.execute_input":"2025-11-17T02:24:11.822445Z","iopub.status.idle":"2025-11-17T02:24:11.83094Z","shell.execute_reply.started":"2025-11-17T02:24:11.822412Z","shell.execute_reply":"2025-11-17T02:24:11.829507Z"}},"outputs":[],"execution_count":null},{"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\nimport tensorflow as tf\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport keras\nimport os\nimport joblib\n\nIMG_SIZE = (480, 480)\ntargets = [\"Dry_Green_g\", \"Dry_Dead_g\", \"Dry_Clover_g\", \"GDM_g\", \"Dry_Total_g\"]\n\ndef load_image(path, labels=None):\n    img = tf.io.read_file(path)\n    img = tf.image.decode_jpeg(img, channels=3)\n    img = tf.image.resize_with_pad(img, IMG_SIZE[0], IMG_SIZE[1])\n    img = tf.cast(img, tf.float32) / 255.0\n    return img, labels\n    \nmodel = keras.models.model_from_json(open(\"/kaggle/input/biomassv1/biomass_EfficientNetV2L_70.json\").read())\nmodel.load_weights(\"/kaggle/input/biomassv1/biomass_EfficientNetV2L_70.weights.h5\", skip_mismatch=True)\n\nscaler = joblib.load(f\"/kaggle/input/biomassv1/biomass_EfficientNetV2L_70_scaler.pkl\")\n\ntest_df = pd.read_csv(\"/kaggle/input/csiro-biomass/test.csv\")  # must contain image_path, sample_id\n\nimg_list =[]\nrows = []\nfor img_path in test_df[\"image_path\"]:\n    if img_path in img_list:\n        continue\n    img_list.append(img_path)\n    full_path = os.path.join(\"/kaggle/input/csiro-biomass\", img_path)\n    img, labels = load_image(full_path)\n    arr = np.array(img) / 255.0\n    arr = np.expand_dims(arr, 0)\n    pred = model.predict(arr)\n    pred = scaler.inverse_transform(pred)\n    for name, val in zip(targets, pred[0]):\n        rows.append({\"sample_id\": f\"{os.path.basename(img_path).replace('.jpg','')}__{name}\", \"target\": val})\n\nsub = pd.DataFrame(rows)\nsub.to_csv(\"submission.csv\", index=False)\nprint(\"✅ submission.csv generated successfully.\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-11-17T02:21:32.546908Z","iopub.execute_input":"2025-11-17T02:21:32.547402Z","iopub.status.idle":"2025-11-17T02:22:24.544035Z","shell.execute_reply.started":"2025-11-17T02:21:32.547373Z","shell.execute_reply":"2025-11-17T02:22:24.542711Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python -m pip install /kaggle/input/biomass/tensorflow-2.20.0.dev0-cp311-cp311-linux_x86_64.whl","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-11-17T01:48:28.204325Z","iopub.execute_input":"2025-11-17T01:48:28.204766Z","iopub.status.idle":"2025-11-17T01:48:36.224946Z","shell.execute_reply.started":"2025-11-17T01:48:28.204728Z","shell.execute_reply":"2025-11-17T01:48:36.223656Z"},"jupyter":{"outputs_hidden":true},"collapsed":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nos.listdir('/kaggle/input/biomass')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-11-17T01:27:29.574838Z","iopub.execute_input":"2025-11-17T01:27:29.575216Z","iopub.status.idle":"2025-11-17T01:27:29.587708Z","shell.execute_reply.started":"2025-11-17T01:27:29.575183Z","shell.execute_reply":"2025-11-17T01:27:29.586408Z"}},"outputs":[],"execution_count":null}]}