{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":98450,"databundleVersionId":11749951,"sourceType":"competition"}],"dockerImageVersionId":31012,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Visible Spectrum: Split Data by Shape","metadata":{}},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:09:17.389273Z","iopub.execute_input":"2025-05-16T03:09:17.389568Z","iopub.status.idle":"2025-05-16T03:09:17.396195Z","shell.execute_reply.started":"2025-05-16T03:09:17.389541Z","shell.execute_reply":"2025-05-16T03:09:17.395097Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"paths=[]\nfor dirname, _, filenames in os.walk('/kaggle/input/beyond-visible-spectrum-ai-for-agriculture-2025/ot/ot'):\n    for filename in filenames:\n        path=os.path.join(dirname, filename)\n        paths+=[path]\npaths.sort()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:09:17.397140Z","iopub.execute_input":"2025-05-16T03:09:17.397443Z","iopub.status.idle":"2025-05-16T03:09:18.751524Z","shell.execute_reply.started":"2025-05-16T03:09:17.397415Z","shell.execute_reply":"2025-05-16T03:09:18.750665Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/beyond-visible-spectrum-ai-for-agriculture-2025/train.csv')\nset(train['label'].unique().tolist())==set(list(range(101)))\nclass_names = [str(i) for i in range(101)]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:09:18.752510Z","iopub.execute_input":"2025-05-16T03:09:18.752867Z","iopub.status.idle":"2025-05-16T03:09:18.766182Z","shell.execute_reply.started":"2025-05-16T03:09:18.752836Z","shell.execute_reply":"2025-05-16T03:09:18.765127Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"file_path_shape=[]\nfor path in paths:\n    file=path.split('/')[-1]\n    try:\n        A=np.load(path)\n        file_path_shape+=[(file,path,A.shape)]\n    except:\n        print(path)\n        file_path_shape+=[(file,path,np.nan)]\n        continue","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:09:18.768973Z","iopub.execute_input":"2025-05-16T03:09:18.769295Z","iopub.status.idle":"2025-05-16T03:09:26.143238Z","shell.execute_reply.started":"2025-05-16T03:09:18.769273Z","shell.execute_reply":"2025-05-16T03:09:26.142484Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data=pd.DataFrame(data=file_path_shape,columns=['id','path','shape'])\ndisplay(data)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:09:26.144211Z","iopub.execute_input":"2025-05-16T03:09:26.144557Z","iopub.status.idle":"2025-05-16T03:09:26.161159Z","shell.execute_reply.started":"2025-05-16T03:09:26.144532Z","shell.execute_reply":"2025-05-16T03:09:26.160047Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"set(data['shape'].tolist())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:09:26.162775Z","iopub.execute_input":"2025-05-16T03:09:26.163158Z","iopub.status.idle":"2025-05-16T03:09:26.175781Z","shell.execute_reply.started":"2025-05-16T03:09:26.163134Z","shell.execute_reply":"2025-05-16T03:09:26.174909Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/beyond-visible-spectrum-ai-for-agriculture-2025/train.csv')\ntest=pd.read_csv('/kaggle/input/beyond-visible-spectrum-ai-for-agriculture-2025/test.csv')\ntrain['traintest']='train'\ntest['traintest']='test'\ndata2=pd.concat([train,test],axis=0)\ndata=pd.merge(data,data2,on='id',how='left')\ndisplay(data)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:11:52.827543Z","iopub.execute_input":"2025-05-16T03:11:52.828483Z","iopub.status.idle":"2025-05-16T03:11:52.866704Z","shell.execute_reply.started":"2025-05-16T03:11:52.828451Z","shell.execute_reply":"2025-05-16T03:11:52.865814Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data128=data[data['shape']==(128, 128, 125)]\ndata057=data[data['shape']==(128, 57, 125)]\ndata128.to_csv('data128.csv',index=False)\ndata057.to_csv('data057.csv',index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:12:24.186786Z","iopub.execute_input":"2025-05-16T03:12:24.187103Z","iopub.status.idle":"2025-05-16T03:12:24.218514Z","shell.execute_reply.started":"2025-05-16T03:12:24.187080Z","shell.execute_reply":"2025-05-16T03:12:24.217557Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"display(data128)\ndisplay(data057)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-05-16T03:12:26.934271Z","iopub.execute_input":"2025-05-16T03:12:26.934640Z","iopub.status.idle":"2025-05-16T03:12:26.950942Z","shell.execute_reply.started":"2025-05-16T03:12:26.934614Z","shell.execute_reply":"2025-05-16T03:12:26.949925Z"}},"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}]}