{"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":"nvidiaTeslaT4","dataSources":[{"sourceId":111512,"databundleVersionId":13502500,"sourceType":"competition"}],"dockerImageVersionId":31090,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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":{"iopub.status.busy":"2025-08-25T20:28:35.897341Z","iopub.execute_input":"2025-08-25T20:28:35.898145Z","iopub.status.idle":"2025-08-25T20:28:37.122811Z","shell.execute_reply.started":"2025-08-25T20:28:35.898108Z","shell.execute_reply":"2025-08-25T20:28:37.122117Z"},"collapsed":true,"jupyter":{"outputs_hidden":true}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# clone the code from https://github.com/hyper-object/2026-ICASSP-SPGC\n!git clone https://github.com/hyper-object/2026-ICASSP-SPGC.git","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:13:27.089967Z","iopub.execute_input":"2025-08-26T04:13:27.090161Z","iopub.status.idle":"2025-08-26T04:13:27.923016Z","shell.execute_reply.started":"2025-08-26T04:13:27.090144Z","shell.execute_reply":"2025-08-26T04:13:27.922094Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install --upgrade \"colour-science>=0.4.2\"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:13:34.489608Z","iopub.execute_input":"2025-08-26T04:13:34.489919Z","iopub.status.idle":"2025-08-26T04:13:40.384684Z","shell.execute_reply.started":"2025-08-26T04:13:34.489889Z","shell.execute_reply":"2025-08-26T04:13:40.383999Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import sys\nsys.path.insert(0, \"/kaggle/working/2026-ICASSP-SPGC\") \nif \"datasets\" in sys.modules:\n    del sys.modules[\"datasets\"]\n\nimport os\nopen(os.path.join(\"/kaggle/working/2026-ICASSP-SPGC\", \"datasets\", \"__init__.py\"), \"a\").close()\n\nimport random\nimport numpy as np\nfrom pathlib import Path\n\n# %matplotlib widget\nimport matplotlib.pyplot as plt\n\nimport torch\nfrom torch.utils.data import DataLoader\n\nfrom datasets.hyper_object import HyperObjectDataset\nfrom datasets.pairing import ModalitySpec\nfrom datasets.base import JointTransform\nfrom datasets.transform import random_flip\n\nfrom utils.visualizations import visualize_sample_overview, visualize_hsi_grid, interactive_hsi_viewer, plot_spectral_profiles, render_srgb_preview, sam_mask, kmeans_mask","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:16:36.876150Z","iopub.execute_input":"2025-08-26T04:16:36.876735Z","iopub.status.idle":"2025-08-26T04:16:37.569592Z","shell.execute_reply.started":"2025-08-26T04:16:36.876713Z","shell.execute_reply":"2025-08-26T04:16:37.569020Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ds = HyperObjectDataset(\n    data_root=\"/kaggle/input/2026-icassp-hyper-object-challenge-track-1\",\n    track=1,  # 1 for mosaic, 2 for rgb_2\n    train=True,\n    transforms=JointTransform(random_flip),\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:16:40.480447Z","iopub.execute_input":"2025-08-26T04:16:40.481263Z","iopub.status.idle":"2025-08-26T04:16:41.012270Z","shell.execute_reply.started":"2025-08-26T04:16:40.481237Z","shell.execute_reply":"2025-08-26T04:16:41.011684Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"loader = DataLoader(ds, batch_size=2, shuffle=True, num_workers=4, pin_memory=True)\nsample = next(iter(loader))\nprint(\"Sample keys:\", sample.keys())\nprint(\"Sample Cube shape:\", sample[\"output\"].shape)\nprint(\"Sample Mosaic shape:\", sample[\"input\"].shape)\nprint(\"Sample ids:\", sample[\"id\"])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:17:44.252881Z","iopub.execute_input":"2025-08-26T04:17:44.253200Z","iopub.status.idle":"2025-08-26T04:18:03.920376Z","shell.execute_reply.started":"2025-08-26T04:17:44.253170Z","shell.execute_reply":"2025-08-26T04:18:03.919614Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 1) Single-row overview\nvisualize_sample_overview(sample, index=1, cube_bands=(10, 30, 50), figsize = (10,5))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:18:08.320096Z","iopub.execute_input":"2025-08-26T04:18:08.320408Z","iopub.status.idle":"2025-08-26T04:18:09.201762Z","shell.execute_reply.started":"2025-08-26T04:18:08.320379Z","shell.execute_reply":"2025-08-26T04:18:09.200796Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 2) Full 61-band grid\nvisualize_hsi_grid(sample[\"output\"], index=1, wl=np.arange(400, 1001, 10), cols=9, suptitle=str(sample[\"id\"][0]))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:18:13.026621Z","iopub.execute_input":"2025-08-26T04:18:13.027371Z","iopub.status.idle":"2025-08-26T04:18:21.290644Z","shell.execute_reply.started":"2025-08-26T04:18:13.027344Z","shell.execute_reply":"2025-08-26T04:18:21.289727Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 3) Interactive viewer (slider + click spectrum)\nwl_61 = np.arange(400, 1001, 10)\n_ = interactive_hsi_viewer(sample[\"output\"][1], wl=wl_61, init_band=15)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:18:28.839856Z","iopub.execute_input":"2025-08-26T04:18:28.840388Z","iopub.status.idle":"2025-08-26T04:18:29.414443Z","shell.execute_reply.started":"2025-08-26T04:18:28.840364Z","shell.execute_reply":"2025-08-26T04:18:29.413722Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 4) Camera-like sRGB preview\nrgb_preview = render_srgb_preview(sample[\"output\"][1], wl=wl_61, title=str(sample[\"id\"][0]), show_fig = True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-08-26T04:18:34.126015Z","iopub.execute_input":"2025-08-26T04:18:34.126299Z","iopub.status.idle":"2025-08-26T04:18:35.000386Z","shell.execute_reply.started":"2025-08-26T04:18:34.126278Z","shell.execute_reply":"2025-08-26T04:18:34.999645Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}