634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published
637 | by the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # train-yolov8-object-detector-google-drive-colab
2 |
3 |
4 |
5 |
6 | Watch on YouTube: Train Yolo V8 object detector on your custom data | Google Colab | Step by step guide !
7 |
8 |
9 |
10 | ## dataset
11 |
12 | If you want to use the same dataset I used in the video, [here](https://www.patreon.com/posts/how-to-download-91285241) are some instructions on how you can download an object detection dataset from the [Open Images Dataset v7](https://storage.googleapis.com/openimages/web/index.html).
13 |
--------------------------------------------------------------------------------
/TrainYolov8CustomDataset.ipynb:
--------------------------------------------------------------------------------
1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"15VlWAG6Oka9JVmf-bUGexpOIYwaE2l92","timestamp":1697576222734}],"authorship_tag":"ABX9TyMKXXvRm9hw2u6SugcIKGP0"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU","gpuClass":"standard"},"cells":[{"cell_type":"code","execution_count":null,"metadata":{"id":"Dob4YRhec9Fm"},"outputs":[],"source":["### 1. Mount Google Drive ###\n","\n","from google.colab import drive\n","\n","drive.mount('/content/gdrive')"]},{"cell_type":"code","source":["### 2. Define root directory ###\n","\n","ROOT_DIR = '/content/gdrive/My Drive/ComputerVisionEngineer/ObjectDetectionYolov8GoogleColab'"],"metadata":{"id":"xBHfolzSdnR5"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["### 3. Install Ultralytics ###\n","\n","!pip install ultralytics"],"metadata":{"id":"i8yghpa4eEjd"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["### 4. Train model ###\n","\n","import os\n","\n","from ultralytics import YOLO\n","\n","\n","# Load a model\n","model = YOLO(\"yolov8n.pt\") # load pre trained model\n","\n","# Use the model\n","results = model.train(data=os.path.join(ROOT_DIR, \"google_colab_config.yaml\"), epochs=20) # train the model\n"],"metadata":{"id":"oyZJX6PVfE7J"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["### 5. Copy results ###\n","\n","!scp -r /content/runs '/content/gdrive/My Drive/ComputerVisionEngineer/ObjectDetectionYolov8GoogleColab'"],"metadata":{"id":"hbUDdF1Jk5rE"},"execution_count":null,"outputs":[]}]}
--------------------------------------------------------------------------------
/google_colab_config.yaml:
--------------------------------------------------------------------------------
1 | path: '/content/gdrive/My Drive/ComputerVisionEngineer/ObjectDetectionYolov8GoogleColab/data' # dataset root dir
2 | train: images/train # train images (relative to 'path')
3 | val: images/val # val images (relative to 'path')
4 |
5 | names:
6 | 0: squirrel
7 |
8 |
--------------------------------------------------------------------------------