{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":125981,"databundleVersionId":14910697,"sourceType":"competition"}],"dockerImageVersionId":31234,"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\nimport cv2\nimport os\nfrom PIL import Image, ImageFilter\nimport random\nfrom pathlib import Path\nimport matplotlib.pyplot as plt\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\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom keras import Sequential\nfrom keras.layers import Dense, Conv2D, MaxPooling2D, Flatten\nimport json\nfrom IPython.display import display\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\n#from keras.preprocessing.image import ImageDataGenerator","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-25T11:55:43.029028Z","iopub.execute_input":"2025-12-25T11:55:43.029226Z","iopub.status.idle":"2025-12-25T11:55:57.772865Z","shell.execute_reply.started":"2025-12-25T11:55:43.029204Z","shell.execute_reply":"2025-12-25T11:55:57.772094Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# GRID_SIZE = 20\n# NUM_CLASSES = 5  # 0..4\n# BATCH_SIZE = 4\n# EPOCHS = 10\n# LR = 1e-3\n\n# train_images=Path('/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/train/images')\n# train_labels=Path('/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/train/labels')\n# train_vel=Path('/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/train/velocities')\n# test_images=Path('/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/test/images')\n# test_vel=Path('/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/test/velocities')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T08:39:21.184699Z","iopub.execute_input":"2025-12-25T08:39:21.185020Z","iopub.status.idle":"2025-12-25T08:39:21.189760Z","shell.execute_reply.started":"2025-12-25T08:39:21.184985Z","shell.execute_reply":"2025-12-25T08:39:21.189150Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# image_paths = []\n# labels = []\n\n# for json_file in train_labels.glob(\"*.json\"):\n#     with open(json_file) as f:\n#         data = json.load(f)\n#     terrain = data[\"terrain\"]\n\n#     image_file = train_images / (json_file.stem + \".png\")\n\n#     if image_file.exists():\n#         image_paths.append(str(image_file))\n#         labels.append(terrain)\n        \n# encoder = LabelEncoder()\n# labels_encoded = encoder.fit_transform(labels)\n# print(encoder.classes_)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-22T04:45:32.549410Z","iopub.execute_input":"2025-12-22T04:45:32.549737Z","iopub.status.idle":"2025-12-22T04:45:32.706983Z","shell.execute_reply.started":"2025-12-22T04:45:32.549709Z","shell.execute_reply":"2025-12-22T04:45:32.706035Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"base = Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/train/images/0001.png\")\ndesert={'cactus':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/desert/t1_cacti.png\").resize((64,64)),\n        'goal':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/desert/t1_goal.png\").resize((64,64)),\n        'quicksand':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/desert/t1_quicksand.png\").resize((64,64)),\n        'rocks':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/desert/t1_rocks.png\").resize((64,64)),\n        'rover':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/desert/t1_rover.png\").resize((64,64)),\n        'sand':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/desert/t1_sand.png\").resize((64,64))}  # Image to paste 400 times\n\nwidth, height = base.size\nbase_DIR = Path('/kaggle/working/').resolve()\nBase_DIR= base_DIR / \"generated_maps\" / \"desert\"\nBase_DIR.mkdir(exist_ok=True, parents=True)\ntest_dir=Base_DIR / \"test\"\nval_dir=Base_DIR / \"validation\"\ntrain_dir=Base_DIR / \"train\"\ntri=train_dir / \"images\"\ntrl=train_dir / \"labels\"\ntei=test_dir / \"images\"\ntel=test_dir / \"labels\"\nvai=val_dir / \"images\"\nval=val_dir / \"labels\"\ntest_dir.mkdir(exist_ok=True)\ntrain_dir.mkdir(exist_ok=True)\nval_dir.mkdir(exist_ok=True)\ntri.mkdir(exist_ok=True)\ntrl.mkdir(exist_ok=True)\ntei.mkdir(exist_ok=True)\ntel.mkdir(exist_ok=True)\nvai.mkdir(exist_ok=True)\nval.mkdir(exist_ok=True)\nbd=Path('/kaggle/working/').resolve()\nt_dir=bd / 'train'\nv_dir=bd / 'validation'\ndt=t_dir /'desert'\ndv=v_dir / 'desert'\nt_dir.mkdir(exist_ok=True)\nv_dir.mkdir(exist_ok=True)\ndt.mkdir(exist_ok=True)\ndv.mkdir(exist_ok=True)\ntrain_i=Path('/kaggle/working/generated_maps/desert/train/images').resolve()\ntest_i=Path('/kaggle/working/generated_maps/desert/test/images').resolve()\nval_i=Path('/kaggle/working/generated_maps/desert/validation/images').resolve()\ntrain_l='/kaggle/working/generated_maps/desert/train/labels/'\ntest_l='/kaggle/working/generated_maps/desert/test/labels/'\nval_l='/kaggle/working/generated_maps/desert/validation/labels/'\nL=['sand','sand','sand','sand','sand','sand','sand','sand','sand','sand','cactus','rocks','cactus','rocks','quicksand','quicksand','quicksand','rover','goal']\nD={'goal':0, 'rover':1, 'sand':2, 'quicksand':3, 'cactus':4, 'rocks':5}\nfor i in range(1000):\n    if i>899:\n        path=test_l+f'image{i}.txt'\n        F=open(path,'w')\n    elif i>699:\n        path=val_l+f'image{i}.txt'\n        F=open(path, 'w')\n    else:\n        path=train_l+f'image{i}.txt'\n        F=open(path, 'w')\n    x=5\n    s=False\n    e=False\n    y=5\n    while x<1385:\n        y=5\n        while y<1385:\n            r=random.randint(0,18)\n            overlay=desert[L[r]]\n            if r==17 and s==False:\n                s=True\n            elif r==17 and s:\n                continue\n            elif r==18 and e==False:\n                e=True\n            elif r==18 and e:\n                continue\n            x_avg=((x-2.5) + 34.5)/1385\n            y_avg=((y-2.5) + 34.5)/1385\n            F.write(f'{D[L[r]]} {x_avg} {y_avg} {69/1385} {69/1385} \\n')\n            base.paste(overlay, (x, y))\n            y+=69\n        x=x+69\n    d=random.randint(1,10)\n    if d<=2:\n        base = base.filter(ImageFilter.GaussianBlur(radius=2))\n    if i>899:\n        base.save(test_i /f'image{i}.png')\n    elif i>699:\n        base.save(val_i /f'image{i}.png')\n        base.save(dv /f'image{i}.png')\n    else:\n        base.save(train_i /f'image{i}.png')\n        base.save(dt /f'image{i}.png')\n    F.close()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T11:56:18.018197Z","iopub.execute_input":"2025-12-25T11:56:18.018628Z","iopub.status.idle":"2025-12-25T12:09:47.005085Z","shell.execute_reply.started":"2025-12-25T11:56:18.018596Z","shell.execute_reply":"2025-12-25T12:09:47.004460Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"base = Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/train/images/0001.png\")\nforest={'tree':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/forest/t0_tree.png\").resize((64,64)),\n        'goal':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/forest/t0_goal.png\").resize((64,64)),\n        'puddle':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/forest/t0_puddle.png\").resize((64,64)),\n        'startship':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/forest/t0_startship.png\").resize((64,64)),\n        'dirt':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/forest/t0_dirt.png\").resize((64,64))}  # Image to paste 400 times\n\nwidth, height = base.size\n\n# Paste 400 times at random positions\nbase_DIR = Path('/kaggle/working/').resolve()\nBase_DIR= base_DIR / \"generated_maps\" / \"forest\"\nBase_DIR.mkdir(exist_ok=True)\ntest_dir=Base_DIR / \"test\"\nval_dir=Base_DIR / \"validation\"\ntrain_dir=Base_DIR / \"train\"\ntri=train_dir / \"images\"\ntrl=train_dir / \"labels\"\ntei=test_dir / \"images\"\ntel=test_dir / \"labels\"\nvai=val_dir / \"images\"\nval=val_dir / \"labels\"\n\ntest_dir.mkdir(exist_ok=True)\ntrain_dir.mkdir(exist_ok=True)\nval_dir.mkdir(exist_ok=True)\ntri.mkdir(exist_ok=True)\ntrl.mkdir(exist_ok=True)\ntei.mkdir(exist_ok=True)\ntel.mkdir(exist_ok=True)\nvai.mkdir(exist_ok=True)\nval.mkdir(exist_ok=True)\nft=t_dir /'forest'\nfv=v_dir / 'forest'\nft.mkdir(exist_ok=True)\nfv.mkdir(exist_ok=True)\ntrain_i=Path('/kaggle/working/generated_maps/forest/train/images').resolve()\ntest_i=Path('/kaggle/working/generated_maps/forest/test/images').resolve()\nval_i=Path('/kaggle/working/generated_maps/forest/validation/images').resolve()\ntrain_l='/kaggle/working/generated_maps/forest/train/labels/'\ntest_l='/kaggle/working/generated_maps/forest/test/labels/'\nval_l='/kaggle/working/generated_maps/forest/validation/labels/'\nL=['dirt','dirt','dirt','dirt','dirt','dirt','dirt','dirt','dirt','dirt','puddle','puddle','puddle','tree','tree','tree','goal','startship']\nD={'goal':0, 'startship':1, 'dirt':2, 'puddle':3, 'tree':4}\nfor i in range(1000):\n    path=path+f\"image{i}.txt\"\n    if i>899:\n        path=test_l+f'image{i}.txt'\n        F=open(path,'w')\n    elif i>699:\n        path=val_l+f'image{i}.txt'\n        F=open(path, 'w')\n    else:\n        path=train_l+f'image{i}.txt'\n        F=open(path, 'w')\n    x=5\n    s=False\n    e=False\n    y=5\n    while x<1385:\n        y=5\n        while y<1385:\n            r=random.randint(0,17)\n            overlay=forest[L[r]]\n            if r==16 and s==False:\n                s=True\n            elif r==16 and s:\n                continue\n            elif r==17 and e==False:\n                e=True\n            elif r==17 and e:\n                continue\n            x_avg=((x-2.5) + 34.5)/1385\n            y_avg=((y-2.5) + 34.5)/1385\n            F.write(f'{D[L[r]]} {x_avg} {y_avg} {69/1385} {69/1385} \\n')\n            base.paste(overlay, (x, y))\n            y+=69\n        x=x+69\n    d=random.randint(1,10)\n    if d<=2:\n        base = base.filter(ImageFilter.GaussianBlur(radius=2))\n    if i>899:\n        base.save(test_i /f'image{i}.png')\n    elif i>699:\n        base.save(val_i /f'image{i}.png')\n        base.save(fv /f'image{i}.png')\n    else:\n        base.save(train_i /f'image{i}.png')\n        base.save(ft /f'image{i}.png')\n    F.close()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T12:13:02.287417Z","iopub.execute_input":"2025-12-25T12:13:02.287973Z","iopub.status.idle":"2025-12-25T12:24:37.042980Z","shell.execute_reply.started":"2025-12-25T12:13:02.287942Z","shell.execute_reply":"2025-12-25T12:24:37.042261Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"base = Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/train/images/0001.png\")\ndesert={'cactus':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/lab/t2_plasma.png\").resize((64,64)),\n        'goal':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/lab/t2_goal.png\").resize((64,64)),\n        'quicksand':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/lab/t2_glue.png\").resize((64,64)),\n        'rocks':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/lab/t2_wall.png\").resize((64,64)),\n        'rover':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/lab/t2_drone.png\").resize((64,64)),\n        'sand':Image.open(r\"/kaggle/input/the-blind-flight-synapse-drive-ps-1/SynapseDrive_Dataset/assets/lab/t2_floor.png\").resize((64,64))}  # Image to paste 400 times\n\nBase_DIR= base_DIR / \"generated_maps\" / \"lab\"\nBase_DIR.mkdir(exist_ok=True)\ntest_dir=Base_DIR / \"test\"\nval_dir=Base_DIR / \"validation\"\ntrain_dir=Base_DIR / \"train\"\ntri=train_dir / \"images\"\ntrl=train_dir / \"labels\"\ntei=test_dir / \"images\"\ntel=test_dir / \"labels\"\nvai=val_dir / \"images\"\nval=val_dir / \"labels\"\ntest_dir.mkdir(exist_ok=True)\ntrain_dir.mkdir(exist_ok=True)\nval_dir.mkdir(exist_ok=True)\ntri.mkdir(exist_ok=True)\ntrl.mkdir(exist_ok=True)\ntei.mkdir(exist_ok=True)\ntel.mkdir(exist_ok=True)\nvai.mkdir(exist_ok=True)\nval.mkdir(exist_ok=True)\nlt=t_dir /'lab'\nlv=v_dir / 'lab'\nlt.mkdir(exist_ok=True)\nlv.mkdir(exist_ok=True)\ntrain_i=Path('/kaggle/working/generated_maps/lab/train/images').resolve()\ntest_i=Path('/kaggle/working/generated_maps/lab/test/images').resolve()\nval_i=Path('/kaggle/working/generated_maps/lab/validation/images').resolve()\ntrain_l='/kaggle/working/generated_maps/lab/train/labels/'\ntest_l='/kaggle/working/generated_maps/lab/test/labels/'\nval_l='/kaggle/working/generated_maps/lab/validation/labels/'\nL=['sand','sand','sand','sand','sand','sand','sand','sand','sand','sand','cactus','rocks','cactus','rocks','quicksand','quicksand','quicksand','rover','goal']\nD={'goal':0, 'rover':1, 'sand':2, 'quicksand':3, 'cactus':4, 'rocks':5}\nfor i in range(1000):\n    path=path+f\"image{i}.txt\"\n    if i>899:\n        path=test_l+f'image{i}.txt'\n        F=open(path,'w')\n    elif i>699:\n        path=val_l+f'image{i}.txt'\n        F=open(path, 'w')\n    else:\n        path=train_l+f'image{i}.txt'\n        F=open(path, 'w')\n    x=5\n    s=False\n    e=False\n    y=5\n    while x<1385:\n        y=5\n        while y<1385:\n            r=random.randint(0,18)\n            overlay=desert[L[r]]\n            if r==17 and s==False:\n                s=True\n            elif r==17 and s:\n                continue\n            elif r==18 and e==False:\n                e=True\n            elif r==18 and e:\n                continue\n            x_avg=((x-2.5) + 34.5)/1385\n            y_avg=((y-2.5) + 34.5)/1385\n            F.write(f'{D[L[r]]} {x_avg} {y_avg} {69/1385} {69/1385} \\n')\n            base.paste(overlay, (x, y))\n            y+=69\n        x=x+69\n    d=random.randint(1,10)\n    if d<=2:\n        base = base.filter(ImageFilter.GaussianBlur(radius=2))\n    if i>899:\n        base.save(test_i /f'image{i}.png')\n    elif i>699:\n        base.save(val_i /f'image{i}.png')\n        base.save(lv /f'image{i}.png')\n    else:\n        base.save(train_i /f'image{i}.png')\n        base.save(lt /f'image{i}.png')\n    F.close()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T12:26:35.358457Z","iopub.execute_input":"2025-12-25T12:26:35.359244Z","iopub.status.idle":"2025-12-25T12:40:25.150898Z","shell.execute_reply.started":"2025-12-25T12:26:35.359214Z","shell.execute_reply":"2025-12-25T12:40:25.150268Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_ds= tf.keras.utils.image_dataset_from_directory(\n    directory='/kaggle/working/train',\n    labels='inferred',\n    label_mode='int',\n    batch_size=32,\n    image_size=(256,256)\n)\n\nvalidation_ds= tf.keras.utils.image_dataset_from_directory(\n    directory='/kaggle/working/validation',\n    labels='inferred',\n    label_mode='int',\n    batch_size=32,\n    image_size=(256,256)\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:00:59.997770Z","iopub.execute_input":"2025-12-25T13:00:59.998323Z","iopub.status.idle":"2025-12-25T13:01:02.602807Z","shell.execute_reply.started":"2025-12-25T13:00:59.998290Z","shell.execute_reply":"2025-12-25T13:01:02.602269Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def process(image, label):\n  image= tf.cast(image/255, tf.float32)\n  return image, label\n\ntrain_ds= train_ds.map(process)\nvalidation_ds= validation_ds.map(process)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:01:33.140850Z","iopub.execute_input":"2025-12-25T13:01:33.141562Z","iopub.status.idle":"2025-12-25T13:01:33.180476Z","shell.execute_reply.started":"2025-12-25T13:01:33.141530Z","shell.execute_reply":"2025-12-25T13:01:33.179935Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential()\nmodel.add(Conv2D(32, kernel_size=(3,3), padding='valid', activation='relu', input_shape=(256,256,3)))\nmodel.add(MaxPooling2D(pool_size=(2,2), strides=2, padding='valid'))\n\nmodel.add(Conv2D(64,kernel_size=(3,3),padding='valid',activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2),padding='valid',strides=2))\n\nmodel.add(Conv2D(128,kernel_size=(3,3),padding='valid',activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2),padding='valid',strides=2))\n\nmodel.add(Flatten())\nmodel.add(Dense(128, activation='relu'))\nmodel.add(Dense(64, activation='relu'))\nmodel.add(Dense(3, activation=\"softmax\"))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:01:38.649038Z","iopub.execute_input":"2025-12-25T13:01:38.649744Z","iopub.status.idle":"2025-12-25T13:01:39.450139Z","shell.execute_reply.started":"2025-12-25T13:01:38.649713Z","shell.execute_reply":"2025-12-25T13:01:39.449291Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:02:10.519230Z","iopub.execute_input":"2025-12-25T13:02:10.519784Z","iopub.status.idle":"2025-12-25T13:02:10.537960Z","shell.execute_reply.started":"2025-12-25T13:02:10.519756Z","shell.execute_reply":"2025-12-25T13:02:10.537277Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.compile(optimizer='adam',loss='sparse_categorical_crossentropy', metrics=['accuracy'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:02:31.846095Z","iopub.execute_input":"2025-12-25T13:02:31.846687Z","iopub.status.idle":"2025-12-25T13:02:31.854284Z","shell.execute_reply.started":"2025-12-25T13:02:31.846658Z","shell.execute_reply":"2025-12-25T13:02:31.853643Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"history=model.fit(train_ds, epochs=10, validation_data=validation_ds)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:02:36.004840Z","iopub.execute_input":"2025-12-25T13:02:36.005137Z","iopub.status.idle":"2025-12-25T13:09:45.924649Z","shell.execute_reply.started":"2025-12-25T13:02:36.005109Z","shell.execute_reply":"2025-12-25T13:09:45.924014Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#accuracy check\nplt.plot(history.history['accuracy'], color='red', label='train')\nplt.plot(history.history['val_accuracy'], color='blue', label='validation')\nplt.legend()\nplt.show()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#overfitting check\nplt.plot(history.history['loss'], color='red', label='train')\nplt.plot(history.history['val_loss'], color='blue', label='validation')\nplt.legend()\nplt.show()","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip list | grep torch","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T05:02:02.818822Z","iopub.execute_input":"2025-12-25T05:02:02.819066Z","iopub.status.idle":"2025-12-25T05:02:07.361988Z","shell.execute_reply.started":"2025-12-25T05:02:02.819041Z","shell.execute_reply":"2025-12-25T05:02:07.360716Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%pip install ultralytics","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:11:03.085306Z","iopub.execute_input":"2025-12-25T13:11:03.086087Z","iopub.status.idle":"2025-12-25T13:11:08.190087Z","shell.execute_reply.started":"2025-12-25T13:11:03.086054Z","shell.execute_reply":"2025-12-25T13:11:08.189307Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import ultralytics\nultralytics.checks()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:11:57.764304Z","iopub.execute_input":"2025-12-25T13:11:57.765126Z","iopub.status.idle":"2025-12-25T13:12:01.105968Z","shell.execute_reply.started":"2025-12-25T13:11:57.765087Z","shell.execute_reply":"2025-12-25T13:12:01.105455Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import yaml\n\n# Define your configuration\ndata_config = {\n    'path': '/kaggle/working/generated_maps/desert',\n    'train': 'train/images',\n    'val': 'validation/images',\n    'test': 'test/images',\n    'nc': 6,\n    'names': ['goal', 'rover', 'sand', 'quicksand','cactus', 'rocks']\n}\n\n# Write to the working directory\nwith open('/kaggle/working/generated_maps/desert/data.yaml', 'w') as f:\n    yaml.dump(data_config, f, default_flow_style=False, sort_keys=False)\n\nprint(\"data.yaml has been created!\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:31:23.428666Z","iopub.execute_input":"2025-12-25T13:31:23.429376Z","iopub.status.idle":"2025-12-25T13:31:23.436202Z","shell.execute_reply.started":"2025-12-25T13:31:23.429333Z","shell.execute_reply":"2025-12-25T13:31:23.435527Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Define your configuration\ndata_config = {\n    'path': '/kaggle/working/generated_maps/forest',\n    'train': 'train/images',\n    'val': 'validation/images',\n    'test': 'test/images',\n    'nc': 5,\n    'names': ['goal', 'startship', 'dirt', 'puddle','tree']\n}\n\n# Write to the working directory\nwith open('/kaggle/working/generated_maps/forest/data.yaml', 'w') as f:\n    yaml.dump(data_config, f, default_flow_style=False, sort_keys=False)\n\nprint(\"data.yaml has been created!\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:31:26.665979Z","iopub.execute_input":"2025-12-25T13:31:26.666768Z","iopub.status.idle":"2025-12-25T13:31:26.672336Z","shell.execute_reply.started":"2025-12-25T13:31:26.666733Z","shell.execute_reply":"2025-12-25T13:31:26.671654Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Define your configuration\ndata_config = {\n    'path': '/kaggle/working/generated_maps/lab',\n    'train': 'train/images',\n    'val': 'validation/images',\n    'test': 'test/images',\n    'nc': 6,\n    'names': ['goal', 'drone', 'floor', 'glue', 'plasma', 'wall']\n}\n\n# Write to the working directory\nwith open('/kaggle/working/generated_maps/lab/data.yaml', 'w') as f:\n    yaml.dump(data_config, f, default_flow_style=False, sort_keys=False)\n\nprint(\"data.yaml has been created!\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T13:31:29.794003Z","iopub.execute_input":"2025-12-25T13:31:29.794664Z","iopub.status.idle":"2025-12-25T13:31:29.800284Z","shell.execute_reply.started":"2025-12-25T13:31:29.794628Z","shell.execute_reply":"2025-12-25T13:31:29.799618Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!yolo detect train data=/kaggle/working/generated_maps/desert/data.yaml model=yolo11x.pt epochs=30 imgsz=640 batch=-1 name=des","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T14:10:51.101614Z","iopub.execute_input":"2025-12-25T14:10:51.102506Z","iopub.status.idle":"2025-12-25T14:52:05.124203Z","shell.execute_reply.started":"2025-12-25T14:10:51.102467Z","shell.execute_reply":"2025-12-25T14:52:05.123424Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!yolo detect train data=/kaggle/working/generated_maps/forest/data.yaml model=yolo11x.pt epochs=30 imgsz=640 batch=-1 name=forest\n!yolo detect train data=/kaggle/working/generated_maps/lab/data.yaml model=yolo11x.pt epochs=30 imgsz=640 batch=-1 name=lab","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-25T15:12:55.619008Z","iopub.execute_input":"2025-12-25T15:12:55.619380Z","iopub.status.idle":"2025-12-25T16:02:17.215959Z","shell.execute_reply.started":"2025-12-25T15:12:55.619342Z","shell.execute_reply":"2025-12-25T16:02:17.215141Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# labels= ['goal', 'rover', 'sand', 'quicksand','cactus', 'rocks']\n# yolo=cv2.dnn.readNetFromONNX('/kaggle/working/runs/detect/des5/weights')\n# yolo.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)\n# yolo.setPreferable.Target(cv2.dnn.DNN_TARGET_CPU)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# img= cv2.imread('')\n# image= img.copy()\n# row, col, d = image.shape\n# wh=640\n# blob= cv2.dnn.blobFromImage(image, 1/255, (wh, wh),swapRB= True, crop=False)\n# yolo.setInput(blob)\n# preds= yolo.forward()","metadata":{"trusted":true},"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}]}