How to train YOLOv8 Object Detection on Custom Dataset | step by step Tutorial | Google Colab

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025
  • YOLOv8 is the latest version of the highly influential YOLO (You Only Look Once) architecture. YOLOv8 was developed by Ultralytics, a team known for its work on YOLOv3 and YOLOv5.
    YOLOv6 and YOLOv7 started doing segmentation and classification tasks along with the object detection task. YOLOv8 follows the same trend.The model itself is created in PyTorch and runs on both the CPU and GPU.
    GIthub: github.com/dee...
    YOLOv8 github: github.com/ult...
    YOLOv8 Docs: docs.ultralyti...
    Dataset: kaggle.com/dat...
    This tutorial contains:
    1. How to download data
    2. How to prepare a train-val split dataset
    3. How to run training with different configurations
    4. How to save trained model weight on google colab
    5. How to do prediction on images
    6. How to do predictions on videos
    7. How to save images and videos on google drive
    Special Thanks to:
    Video sources:
    Anastasia Shuraeva : www.pexels.com...
    Tima Miroshnichenko : pexels.com/vid...
    Tom Fisk: pexels.com/vid...
    Recommended books:
    1. HANDS ON MACHINE LEARNING WITH SCIKIT LEARN, KERAS & TENSORFLOW: amzn.to/3wkAqeG
    2. Deep Learning with PyTorch: Build, train, and tune neural networks using Python tools: amzn.to/3QX5ivo
    Recommended laptops for Machine Learning and Deep Learning:
    1. Lenovo Legion 5 AMD Ryzen 5 4600H 15: amzn.to/3XSGEOP
    2. Acer Nitro 5: amzn.to/3kE3oU7
    3. Acer Predator Helios 300: amzn.to/3XvAkgi
    Best budget setup:
    1. BenQ GW2480 24-inch (60.5 cm) 1080p monitor: amzn.to/3iY6oKO
    2. Office Chair: amzn.to/3XQEK0Z
    3. Table: amzn.to/3R2b1QI
    4. Mic: amzn.to/3Wv4leT
    #yolov8 #objectdetection #coderzero

ความคิดเห็น • 146

  • @Permian777
    @Permian777 ปีที่แล้ว +8

    Thank you. Thank you. Thank you Mr. Coder Zero. I have spent a year and a half trying to figure out this stupid ass YOLO object detection and finally, courtesy of your video, I have now managed to figure it out. Hot dog! I am now a happy camper. I can now expire in peace!

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      Happy to help 😀

  • @dikshagoyal1000
    @dikshagoyal1000 หลายเดือนก่อน +1

    Thanks a lot man ....❤
    The best video on yolov8 through Google colab🙌🏻

    • @coder_zero
      @coder_zero  หลายเดือนก่อน

      😊😊😊

  • @DikshithaKV
    @DikshithaKV 10 หลายเดือนก่อน +1

    Thank you so much literally searched so many videos, finally found your video, it was a really great help, thank you😄

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      😀

  • @vimalsolanki870
    @vimalsolanki870 ปีที่แล้ว +5

    i tried many tutorial but this tutorial is best and briefly explain each terms thank you very much

  • @jonesin9579
    @jonesin9579 11 หลายเดือนก่อน +2

    Thank youuuuu thank youuuu very much Mr... You helped me a Lot !!! May God Bless you

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      Glad to hear that😀

  • @justavrilm
    @justavrilm 9 หลายเดือนก่อน +1

    thank you so much for being so clear and concise

    • @coder_zero
      @coder_zero  9 หลายเดือนก่อน

      Glad it was helpful! 🤠

  • @shailendralowanshi1016
    @shailendralowanshi1016 2 ปีที่แล้ว +2

    Very good vedio, everything is in detail. Thankyou for that. Keep helping

  • @yiksengtee8402
    @yiksengtee8402 2 ปีที่แล้ว +18

    For those who had the issue of not being able to save the files to "runs/detect/predict" after finish generating at the inferencing section (regardless its for images or videos), try adding "save=True" at the end of the prompt.

    • @aliel7770
      @aliel7770 2 ปีที่แล้ว +1

      Thanks a lot dear

    • @coder_zero
      @coder_zero  2 ปีที่แล้ว +1

      Yes 😃

    • @issamissam769
      @issamissam769 2 ปีที่แล้ว +2

      thank you so muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuch

    • @harrynguyen_03
      @harrynguyen_03 ปีที่แล้ว +2

      bro that was very helpful. It worked

    • @venkatasaikumarb706
      @venkatasaikumarb706 ปีที่แล้ว +2

      Thanks man

  • @sowmiyas2729
    @sowmiyas2729 2 ปีที่แล้ว +3

    Thank you so much, sir, for the excellent explanation. It really helped me in my project. Again thank you, sir.

  • @muhammadkry9499
    @muhammadkry9499 ปีที่แล้ว +2

    Thank sir for the explanation

  • @dorianxjz4070
    @dorianxjz4070 7 หลายเดือนก่อน +1

    Thank you for the tutorial. I'm having trouble on seeing the results on a video. I followed the exact code from your tutorial, and uploaded a test mp4 file. When I infer on the video, the program shows that the video is actually being tested on frame by frame, but when it finishes, it doesnt show up on my drive
    edit:
    leaving my comment up in case anyone has the same problem. The issue was that it takes a while to upload a video to the drive. I used a 30 second video but it took about 10 minutes. Its doesn't upload as quick as an image

    • @coder_zero
      @coder_zero  7 หลายเดือนก่อน

      Use save= True to save video. Find this output path. Then you can use Linux copy command cp to copy this output video to your drive.

  • @RahulVimalkanth
    @RahulVimalkanth 11 หลายเดือนก่อน +1

    Thanks tons sir!

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      Most welcome!

  • @ge440
    @ge440 ปีที่แล้ว +1

    Thank you very much for your video.

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      You are welcome😀

  • @reaze4977
    @reaze4977 2 ปีที่แล้ว +1

    bravo thx for the tutorial sir

  • @2102-ts1ed
    @2102-ts1ed 9 หลายเดือนก่อน +1

    Thank you so much my bro my love

    • @coder_zero
      @coder_zero  8 หลายเดือนก่อน

      😄😄😄

  • @rryann088
    @rryann088 3 หลายเดือนก่อน +1

    thanks a lot!

    • @coder_zero
      @coder_zero  3 หลายเดือนก่อน

      Welcome 🙂

  • @streamovie5601
    @streamovie5601 ปีที่แล้ว +2

    thanks man

  • @obaidulhasansouhag985
    @obaidulhasansouhag985 7 หลายเดือนก่อน +1

    Hey, Your video is very good and easy to understand. Could you make an tutorial how to install YOLO V8 for amd in windows 11? There is a tutorial in amd youtube channel about this but it is too hard to understand. Looking for your quick response.

    • @coder_zero
      @coder_zero  7 หลายเดือนก่อน

      Thank you. I am sorry 😔 I can't help you with this as I have a nvidia system.

  • @lorenzoleongutierrez7927
    @lorenzoleongutierrez7927 ปีที่แล้ว +1

    Great work !

  • @bushrabazai4062
    @bushrabazai4062 ปีที่แล้ว +1

    Thank you so much :)

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      You're welcome!😀

  • @gandharvathite6181
    @gandharvathite6181 10 หลายเดือนก่อน +1

    Nice tutorial man, just one question, how to get the locations (coordinates) of the boxes that are drawn in test images

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      Hi, have a look github.com/ultralytics/ultralytics/issues/7719
      This looks promising.

  • @kadiravcii
    @kadiravcii ปีที่แล้ว +2

    Thank you for the video, sir. However, what I want from you is this: In the last part, I want to open a webcam instead of a video and test whether it recognizes it that way. What can I write?

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      Hi, you can follow this tutorial th-cam.com/video/O9Jbdy5xOow/w-d-xo.htmlsi=jgSZRk7ZjyuCt9o8

  • @drushtinagarkar362
    @drushtinagarkar362 6 หลายเดือนก่อน +1

    greattt

    • @coder_zero
      @coder_zero  6 หลายเดือนก่อน

      Thank you 😊

  • @bayoleems
    @bayoleems ปีที่แล้ว +1

    Thank you so much

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      You're most welcome😄

  • @ramanathreddyg7212
    @ramanathreddyg7212 11 หลายเดือนก่อน +1

    how many epochs and images is better to use for good object detection

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      Hi, it depends on your dataset and project. Also, don't focus on number of images. Focus on the distribution of data. Example: if you take 20000 images of cars in day time and train the model. It will struggle in night time or rainy days or during foggy weather.

  • @AachalGupta-m9x
    @AachalGupta-m9x 9 หลายเดือนก่อน +1

    I have one doubt..we are passing image paths of training and validation in yaml file.what about labels?we are not passing anything related to labels.Then how does the model know

    • @coder_zero
      @coder_zero  9 หลายเดือนก่อน

      In the algorithm, it will replace 'images' with ''labels' and take care of labels 🙂

    • @AachalGupta-m9x
      @AachalGupta-m9x 9 หลายเดือนก่อน

      @@coder_zero okay thanks a lot for this tutorial

  • @kasamrohithreddy2679
    @kasamrohithreddy2679 ปีที่แล้ว +2

    Did you Manually kept some images in test or by division of code

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      Yes, I did. It's a best practice to keep some images for testing. Make sure that model has not seen these during training and validation.

  • @xinloongfoo2951
    @xinloongfoo2951 8 หลายเดือนก่อน

    I would like to ask what if i would like to detect some other objects like resistor, inductor and capacitor which is the electrical component how would i do that?

    • @coder_zero
      @coder_zero  8 หลายเดือนก่อน

      Hi, steps are : data creation, model training. You have to collect images of all required items in various conditions, then annotate in yolo format to create data. Then you can follow this tutorial to train and test the model

  • @lightning00769
    @lightning00769 10 หลายเดือนก่อน +1

    if I have only one class to detect, I have to make changes in the dataset.yaml file right?

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      Yes

    • @lightning00769
      @lightning00769 10 หลายเดือนก่อน

      @@coder_zerothanks!! and hey if you could also help with one more thing please, how can I train this model with videos instead of images?

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      @@lightning00769 have a look at this github.com/ultralytics/ultralytics/issues/7206

  • @somasekhar3731
    @somasekhar3731 8 หลายเดือนก่อน

    can you tell me where didi you downloaded the 8 videos in the drive

  • @bLack-hf6qm
    @bLack-hf6qm 7 หลายเดือนก่อน

    Where I will gets the videos???? They are not in kaggle dataset

  • @marthagichuki9539
    @marthagichuki9539 2 ปีที่แล้ว +3

    Great video and explanation. How do we get the test images? are they part of the content in data folder?

    • @coder_zero
      @coder_zero  2 ปีที่แล้ว +2

      Hi, you can keep some images from the data set for testing purpose.

  • @shreyaspatil5536
    @shreyaspatil5536 ปีที่แล้ว

    one doubt i had the video after testing is getting saved in form of frames and not mp4 what to do

  • @Eren-jq1sk
    @Eren-jq1sk 4 หลายเดือนก่อน

    can we do for this real time pc web cam and identify?

    • @coder_zero
      @coder_zero  3 หลายเดือนก่อน

      Yes, we can.

  • @carlos.sousa.7070
    @carlos.sousa.7070 ปีที่แล้ว +1

    I have a huge dataset and after running it 10-15 epochs I always get an error message saying an image was not found but in reality it was always there in the dataset.
    Can you help?
    In my local environment I never had that error message, but I tried Google Colab because it has more resources.

  • @positiveaura3290
    @positiveaura3290 ปีที่แล้ว +3

    thank you for the tutorial. May i please know why i get this error (FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/yolov8/data/download_images.py.jpg') when i run the codes to split the dataset?

    • @seanolivieri4829
      @seanolivieri4829 ปีที่แล้ว

      Getting the same error

    • @carlos.sousa.7070
      @carlos.sousa.7070 ปีที่แล้ว

      Im also getting the same error

    • @sharathsnair3798
      @sharathsnair3798 ปีที่แล้ว

      Have you got that

    • @MrJeopold
      @MrJeopold ปีที่แล้ว

      inside data.yaml file, try these:
      path: C:\**yourprojectfoldername**\dataset # dataset root dir
      train: images\train # train images (relative to 'path')
      val: images\validation # val images (relative to 'path')

    • @safira604
      @safira604 ปีที่แล้ว

      I had the same error, turns out that if you upload files to drive you need to unselect automatic conversion (Settings > Uploads > Untick convert uploads) so that the format is right for the script. (If it's wrong, you might be getting, for example, ..jpg instead of .jpg. easy to miss)

  • @georginobaltazar
    @georginobaltazar 10 หลายเดือนก่อน

    olá, muito bom o contiúdo, baixei para aprender. vc poderia me passar o link para fazer o download dos arquivos das pastas output, video, vid2, training result e a test imag, não consigo encontrar. agradeceria

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      Sorry I couldn't share output videos.

  • @allea-zb7kl
    @allea-zb7kl 8 หลายเดือนก่อน

    hi, I have a question. if I divide the dataset into training and testing only, is it necessary to run the validation part? and if not, during inference how to find out the mAP?

    • @coder_zero
      @coder_zero  8 หลายเดือนก่อน

      You can create a custom function for this.

    • @allea-zb7kl
      @allea-zb7kl 8 หลายเดือนก่อน

      @@coder_zero If I split the data into train, validation, and test sets, is the mAP calculated based on the validation part, or do we need to create a custom function to determine the mAP from the test data?

  • @alfibima4247
    @alfibima4247 2 ปีที่แล้ว +1

    Thank you for sharing.
    I want to ask something. I have trained data on colab. But the color of the bounding box between class 1 and the others is almost the same. how to change bounding box color?

    • @coder_zero
      @coder_zero  2 ปีที่แล้ว

      We can use the python version of inference codem it will give the bboxes. Then we can use cv2 for custom color 😃

  • @sevenkliccs
    @sevenkliccs ปีที่แล้ว +1

    what a great explanation. I'm wondering how can i generate the labels from images into those format? again thank you sir

    • @coder_zero
      @coder_zero  ปีที่แล้ว +1

      Hi, you can use labelImg for annotation

    • @ajarivas72
      @ajarivas72 ปีที่แล้ว

      @@coder_zero
      Is there a labeling software not restricted to boxes ?

  • @shakilsyed
    @shakilsyed ปีที่แล้ว +1

    My dataset is consisting 500 images but it only training 51 images why? what would be the problem?

    • @ajarivas72
      @ajarivas72 ปีที่แล้ว +1

      Are the 500 images anotatted?

    • @coder_zero
      @coder_zero  ปีที่แล้ว +1

      Hi, please make sure you annotate all images. Splitting of data should be done carefully. And ensure you give the correct path to the model during training.

  • @PrincePH
    @PrincePH 10 หลายเดือนก่อน

    Where can we find the test_images dataset? same with the videos

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      Hi, You can take videos and images from internet. I have done that only. The main process of this video is to show the training process. You can follow the tutorial with your own dataset. 😀

    • @PrincePH
      @PrincePH 10 หลายเดือนก่อน

      @@coder_zero it is working ty

    • @PrincePH
      @PrincePH 10 หลายเดือนก่อน

      @@coder_zero Hello! Is there other way to not purchase GPU in the colab?

    • @PrincePH
      @PrincePH 10 หลายเดือนก่อน

      @@coder_zero Hello, can i implement this in the GUI? And which one

  • @ArifHussain-fs5jz
    @ArifHussain-fs5jz ปีที่แล้ว +1

    Please make a video Yolov8 for semantic segmentation; I'm working on it but getting errors.

    • @ArifHussain-fs5jz
      @ArifHussain-fs5jz ปีที่แล้ว

      RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 107 but got size 0 for tensor number 1 in the list.

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      hi, working on it. Will release soon :)

    • @ArifHussain-fs5jz
      @ArifHussain-fs5jz ปีที่แล้ว

      @@coder_zero thanks

    • @rachakondasaiswaroop8993
      @rachakondasaiswaroop8993 ปีที่แล้ว

      ​@@ArifHussain-fs5jz hey, i am getting the same error please let me know if you solved it.

  • @javovichluqsman5492
    @javovichluqsman5492 ปีที่แล้ว

    Thanks for the video sir, but what about datasets that does not have any annotated box?

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      Hi, you can create your own dataset. Have a look at this video th-cam.com/video/v-HIYfOqQeU/w-d-xo.html

  • @jibrilisah1
    @jibrilisah1 ปีที่แล้ว

    please i'm having a problem with the spliting, how dont see where the code reads the dataset folder

    • @jibrilisah1
      @jibrilisah1 ปีที่แล้ว

      i couldnt get the automation of spliting

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      Hi, it's a simple function. It creates a list of all image dirs and split into 80 : 20. Then copies the images and their label files into specific folders. You can create your own custom function for this train-val split.

  • @sheicodes7393
    @sheicodes7393 2 ปีที่แล้ว +1

    is it advisable to use jupyter nb in vscode than google colab to train more than 10k images? suppose i have a ryzen 7 laptop

    • @coder_zero
      @coder_zero  2 ปีที่แล้ว

      Hi you can use jupyter nb. Change the directories accordingly and then set the batch size to 8

  • @vikashkumar-cr7ee
    @vikashkumar-cr7ee ปีที่แล้ว

    Hi Deepak I couldn't find any video for inferencing on kaggle . Where did you get that ?

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      Hi, its a good practice to follow the notebook but work with your own data according to your own project.

  • @kemalkartal366
    @kemalkartal366 ปีที่แล้ว

    hello,
    Can we add the object trained with the custom dataset to the other 80 object YOLO weights? As a single weight of 80+1. Can we increase the weight of the existing 80 objects?
    thanks.
    normally yolo weight consists of 80 objects.
    Can we add new objects to objects of this weight by training with custom datasets?

    • @coder_zero
      @coder_zero  ปีที่แล้ว +1

      Hi, I have never tried this. But, theoretically you can try creating new weights by taking average of your pre- trained weights.

  • @anyhow8174
    @anyhow8174 ปีที่แล้ว +1

    For some reason, when I tried to use the .yaml, it says that dataset could not be found, any thoughts on why that happened?

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      Please ensure that you have created data folder structure as we have discussed in the tutorial. Then you have put the correct directory in the dataset.yaml

    • @anyhow8174
      @anyhow8174 ปีที่แล้ว

      @@coder_zero ay yes it's done, thanks
      is there any way for this model to be fine-tuned? if yes, then what kind? and what exactly are the parameters within the model?

  • @andresbuitront2564
    @andresbuitront2564 ปีที่แล้ว +1

    hi, nice video, i have a trouble the predict model runs well but doesnt create /runs/detect/predict folder in yolo 8.0.46 maybe you know why?

  • @hamzawi2752
    @hamzawi2752 ปีที่แล้ว +1

    Thank you so much, but you did not talk about the annotation.

    • @coder_zero
      @coder_zero  ปีที่แล้ว +1

      Hi, you can use labelImg for annotations. I will be creating a short video on annotations soon.

  • @IshiKag-v7i
    @IshiKag-v7i ปีที่แล้ว

    what about the accuracy of the model?

    • @coder_zero
      @coder_zero  11 หลายเดือนก่อน

      In detection model we focus on mAP value. This gives a good sense on model performance.

  • @tonysiu8562
    @tonysiu8562 ปีที่แล้ว

    Is the GPU instant provided by google colab free to use?

    • @coder_zero
      @coder_zero  ปีที่แล้ว +1

      Hi, yeah, GPU instance is free upto some usage limit. After that you can wait for 24 hr to get the free version again.

  • @MARTINKWESIMAWUSI
    @MARTINKWESIMAWUSI ปีที่แล้ว

    Where is the google colab code? I'm new to YOLO. I have downloaded the dataset but I can't follow the tutorial. Can you please share the Google colab code so I can follow the tutorial.
    Thank you.

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      Hi, you can find the notebook at github.com/deepakat002/yolov8

  • @Anutosh13
    @Anutosh13 ปีที่แล้ว

    after inferencing code no run directory created ????

    • @Anutosh13
      @Anutosh13 ปีที่แล้ว

      help bro
      this was the easiest video on yt and im stuck

    • @chiragubnare2944
      @chiragubnare2944 ปีที่แล้ว

      @@Anutosh13 add another argument save=True in the inferencing cell

    • @Anutosh13
      @Anutosh13 ปีที่แล้ว

      @@chiragubnare2944 yupp did that, thank you

  • @Anutosh13
    @Anutosh13 ปีที่แล้ว

    why my results are not getting saved after executing inferencing step???

    • @Anutosh13
      @Anutosh13 ปีที่แล้ว

      hey help bro I'm stuck

  • @afriquemodel2375
    @afriquemodel2375 ปีที่แล้ว +1

    HOW TO CONVERT MODEL TO TENSORFLOW MODEL?

    • @coder_zero
      @coder_zero  ปีที่แล้ว

      hi, you can use yolo export model=yolov8n.pt format=pb
      for details about supported models, have a look at github.com/ultralytics/ultralytics/blob/16639b60ebc63111d0283edf9cf37f4b5ce479b9/ultralytics/engine/exporter.py

  • @zainnaveed2196
    @zainnaveed2196 10 หลายเดือนก่อน

    Sir from where we find these 8 video

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      Hi, you don't need these videos. You can follow the tutorial with your own dataset 😃

  • @kishoreg8835
    @kishoreg8835 ปีที่แล้ว

    please train paddle ocr on colab

  • @manisharya2138
    @manisharya2138 ปีที่แล้ว

    can provide drive link of video dataset

    • @coder_zero
      @coder_zero  10 หลายเดือนก่อน

      Sorry, I don't have that anymore. Please follow this tutorial with your own dataset. In this way it will be very helpful 😃