{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.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":171880115,"sourceType":"kernelVersion"}],"dockerImageVersionId":30683,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-06-15T14:09:28.00934Z","iopub.execute_input":"2024-06-15T14:09:28.010106Z","iopub.status.idle":"2024-06-15T14:09:28.013996Z","shell.execute_reply.started":"2024-06-15T14:09:28.010069Z","shell.execute_reply":"2024-06-15T14:09:28.013121Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Display generic output messages\n!pip install colorama","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:09:28.015434Z","iopub.execute_input":"2024-06-15T14:09:28.015691Z","iopub.status.idle":"2024-06-15T14:09:42.056905Z","shell.execute_reply.started":"2024-06-15T14:09:28.015669Z","shell.execute_reply":"2024-06-15T14:09:42.055977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!mkdir -p /kaggle/working/data","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:09:42.058217Z","iopub.execute_input":"2024-06-15T14:09:42.058511Z","iopub.status.idle":"2024-06-15T14:09:43.003669Z","shell.execute_reply.started":"2024-06-15T14:09:42.058484Z","shell.execute_reply":"2024-06-15T14:09:43.002529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!cp -r /kaggle/input/notebook200225dc51/refactored_data/ /kaggle/working/","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:09:43.006824Z","iopub.execute_input":"2024-06-15T14:09:43.007552Z","iopub.status.idle":"2024-06-15T14:09:43.955195Z","shell.execute_reply.started":"2024-06-15T14:09:43.007511Z","shell.execute_reply":"2024-06-15T14:09:43.953933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Clone the YoloV9 repository, install the libray, and obtain the model\n!git clone https://github.com/WongKinYiu/yolov9.git\n!pip install -r /kaggle/working/yolov9/requirements.txt\n!wget https://github.com/WongKinYiu/yolov9/releases/download/v0.1/gelan-c.pt","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:09:43.956722Z","iopub.execute_input":"2024-06-15T14:09:43.957033Z","iopub.status.idle":"2024-06-15T14:10:00.240831Z","shell.execute_reply.started":"2024-06-15T14:09:43.957005Z","shell.execute_reply":"2024-06-15T14:10:00.239876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Copy training metadata\n!cp -r /kaggle/input/notebook200225dc51/yolo.yaml /kaggle/working/\n!cp -r /kaggle/input/notebook200225dc51/train.txt /kaggle/working/yolov9/\n!cp -r /kaggle/input/notebook200225dc51/valid.txt /kaggle/working/yolov9/","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:10:34.336378Z","iopub.execute_input":"2024-06-15T14:10:34.336731Z","iopub.status.idle":"2024-06-15T14:10:37.213951Z","shell.execute_reply.started":"2024-06-15T14:10:34.336703Z","shell.execute_reply":"2024-06-15T14:10:37.21277Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMAGE_SIZE = 1024","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:10:39.106462Z","iopub.execute_input":"2024-06-15T14:10:39.107335Z","iopub.status.idle":"2024-06-15T14:10:39.112434Z","shell.execute_reply.started":"2024-06-15T14:10:39.107296Z","shell.execute_reply":"2024-06-15T14:10:39.11159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip uninstall -y wandb","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:10:41.227752Z","iopub.execute_input":"2024-06-15T14:10:41.228089Z","iopub.status.idle":"2024-06-15T14:10:45.608577Z","shell.execute_reply.started":"2024-06-15T14:10:41.22806Z","shell.execute_reply":"2024-06-15T14:10:45.607597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def train_model():\n    # Start the training script\n    !torchrun --nproc_per_node=2 --master_port 9527 /kaggle/working/yolov9/train.py --device 0,1 --sync-bn --img {IMAGE_SIZE} --cfg /kaggle/working/yolov9/models/detect/gelan-c.yaml --batch-size 8 --epochs 50 --data yolo.yaml --weights /kaggle/working/gelan-c.pt --hyp /kaggle/working/yolov9/data/hyps/hyp.scratch-high.yaml --min-items 0 --close-mosaic 15","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:10:47.078496Z","iopub.execute_input":"2024-06-15T14:10:47.078857Z","iopub.status.idle":"2024-06-15T14:10:47.085465Z","shell.execute_reply.started":"2024-06-15T14:10:47.078827Z","shell.execute_reply":"2024-06-15T14:10:47.084425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_model()","metadata":{"execution":{"iopub.status.busy":"2024-06-15T14:10:49.447853Z","iopub.execute_input":"2024-06-15T14:10:49.448199Z","iopub.status.idle":"2024-06-15T14:12:39.571662Z","shell.execute_reply.started":"2024-06-15T14:10:49.448173Z","shell.execute_reply":"2024-06-15T14:12:39.570561Z"},"trusted":true},"execution_count":null,"outputs":[]}]}