IMAGE CLASSIFICATION with Yolov8 custom dataset | Computer vision tutorial
ฝัง
- เผยแพร่เมื่อ 13 มิ.ย. 2024
- Code: github.com/computervisioneng/...
0:00 Intro
0:41 Dataset
1:54 Data structure
4:50 Train method 1: Python in local environment
12:02 Train method 2: Command line
14:35 Train method 3: Python Google Colab
25:25 Validate model
36:48 Predict
44:48 Outro
#computervision #yolov8 #imageclassification #computervisiontutorial
Did you enjoy this video? Try my premium courses! 😃🙌😊
● End-To-End Computer Vision: Build and Deploy a Video Summarization API bit.ly/3tyQX0M
● Hands-On Computer Vision in the Cloud: Building an AWS-based Real Time Number Plate Recognition System bit.ly/3RXrE1Y
● Machine Learning Entrepreneur: How to start your entrepreneurial journey as a freelancer and content creator bit.ly/4bFLeaC
All my premium courses are available to the Computer Vision Experts in my Patreon. 😉
www.patreon.com/ComputerVisionEngineer
I searched for it an entire day, and then I found this guy 😭. GOD BLESS you mann 🔥🔥.
The best tutorial I've seen, and so glad to see someone show the code on the local environment and not Google Colab!
Thank you! Yeah agreed, Google Colab is amazing but it is not an IDE. 😅🙌
Hi Felipe, your videos are beyond amazing! Thankyou for your tutorial.
Thank you!! 😃 Glad you enjoyed it! 🙌
Thanks a lot man, this was everything i needed to get started. saved a lot of time. thanks a lot. lots of support for now and future as well!
It works! Thank you very much!
Thank you so much for the video Felipe!
You are welcome! 😃🙌
Thanks for your tutorials, very good and accessible for "engrish" speakers like me , your channel realy deservs more Subs
Hey Bruno, thank you! I am glad you find the channel useful! 😃💪
Thank you for the detailed explanation ✌
You are welcome! 🙌
More power to you, thanks for a lot for this beautiful video. A lot of thanks. It's really help me today.
😊 You are welcome! I am glad it was helpful, Muhammad! 🙌💪
Muchas gracias Felipe! Me resultó de gran utilidad! Me encanta tu contenido, eres un fenómeno y te pareces a Melendi! Saludos!
😂 Me parezco un poco sí. Me alegro que el contenido te sea útil! 😃🙌
Thankyou.......Its awesome! This video helped a lot.
You are welcome! Glad it helped! 😃🙌
Hi Felipe! your videos are awesome! It would be more awesome if you could make a video about how to use transfer learning for training a new YOLOv8 classification/object detection model using a pre-trained model! I've been looking for a detailed video but literally none of them explain step by step or go into details enough. I'd really really appreciate it! 🙏
Hey Lucas, thank you! I am glad you enjoy my videos. 😊 Do you mean transfer learning from an existing yolov8 model?
@@ComputerVisionEngineer No, I meant training a new Yolov8 model from an existing pre-trained model (for example a TFlite model). btw, I'm new to all this stuff, so I don't even know if it's possible to do transfer learning between models with different architecture, but in my case, I'm working on a project that I need to train a new model for it. I have a TFlite pre-trained model (only the model file, no weights, no documentation, no dataset) that I want to train a new model based on it. I've created a new dataset for training a YOLOv8 model and it has more than 6000 images (of fish) for 6 classes, but I'm wondering if I can use that TFlite pre-trained model to increase the accuracy of my new yolov8 model during training, if that makes sense.
Oh I see. You would need to do some research, but I would say is unlikely converting your model from tflite to yolov8 is possible. 🤔
Amazing VIdeo. Gotta see if yolov8 holds up to my data though
Nice work man.
Thank you!
Still I'm completing the whole 12hrs video and this popped up. You're so fast Felipe!
Just a small request: If possible please also make how to deploy these applications on the web
😃🔥🚀 Sure, web apps and web deployments coming up! 💪💪
@@ComputerVisionEngineer Excited for it💥
HI!
i was making models using YOLO v8, and i found that if you change the imgsz=64, into a bigger dimensions which fits your dataset better, then you can have a much better model, and the high validation loss will reduce tremendously.
thanks for the great tutorials!
Thank you for your contribution! 🙌
Hi Filipe... Could you help us understand how to predict the classes for a whole folder of the images ?
Hi @ComputerVisionEngineer, i just want to ask what are the folders/files inside your val folder?
solid💯
hello , when predict an image class , can you edit the colour of the labels ? the colour of the labels is white and i cant see properly the predicted class plotted inside the white background image
Thanks for this video
You are welcome. 🙂
I have a question regarding getting a confusion matrix in the result section. I trained the classification model on my custom data by watching your video and I got exactly the same type of result that you showed in the video. Is there any way that I can also get the confusion matrix, F-1, and precision-recall curve?
Thanks a lot for the great tutorial.
Hi Felipe, have a doubt,
For image classification do we need to annotate the images like object detection???
Felipe, I love your accent !
Cool, glad you enjoy it! 😄🙌
thank you
Where exactly in the code it is set to be yolov8? I have a working yolov5 real time object detection. Can I use this trained model or should I re-train it to v5?
Thank you for a detailed and well explained video. I used it with my own set pf pictures - working great. My next step is to use this classification results on a video recognition on Jetson Nano. Do you have such a video or planning to?
Great! I don't have such a video, maybe I will make one in the future. 🙌
I trained a model in my Windows 11 laptop and it worked correctly in my laptop but when I use that model for my classification work in Raspberry pi 4 (almost like linux), I just got got an error message called "AttributeError: shape", do you have any suggestions Sir, thank you.
What is the most efficient Image Classification model? How does Yolov8 compare to EfficientNet or scikit-learn in terms of Image classification efficiency?
Facing issue of error: OpenCV(4.7.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' , could you help to resolve it
Hello sir, is it possible to convert it into tflite model with labels.txt file and implement it on flutter? Thank you!
Impressive
💪💪
Thank you so much for the video! It's great, but I have a question regarding the dimensions of the images in the training set, and that is that as we can see, you set the parameter imgsz=64, which makes me think that the image entries should be in a size of (64x64)px, but those are not the dimensions we see. Is it necessary to do this resize or does YOLOv8 automatically internally do this resizing of the images?
I would be very grateful if someone could answer this question for me.
The default value for imgsz is 640. It means yolov8 will internally resize the images to that size in order to do the training / inference. 🙌
Hey , I dont know if you’d reply but you’d be saving my life if you do,
I will train my model with this video thanks in advance but I want to implement it to open cv to real time object detection how can I do it?
Hi Felipe, I was wondering if your method is applicable for those running the model on google collab or running it on VSC with an AMD GPU.
You can train from a Google colab. Not sure about the amd gpu.
In the dataset, there are 2 non-functional files: "rain141.jpg" and "shine131.jpg". They cause an error during training.
Thank you for your contribution!
THANKS A LOOOOOOOTTTTTTTTT
Thank you. You've done me a great favor
Are the steps the same if I use yolov5?
Hi Felippe, Hope you are doing good. I enjoy your teaching a lot. I was trying this tutorial and i tried to train the model but iam getting 'NoneType' object has no attribute 'shape' error after 19% of epoch 1 (this value is changing every time i run the code) . I was hoping that you can help me sort the issue 🙏🏽
Hey, it may be due to an issue in a couple of images. Go through the comments, other user has pointed out the images which are causing the error. 🙌
Hi sir felipe im using raspi and in training its not continuing in epoch with 0%
Hi, any idea on how to set up my device GPU for training a YoloV8 model in my local environment?
Hey, do you think it needs setup? It doesn't use your gpu during training?
would anyone mind assisting me with a question. I'm trying to take all sms data from a Samsung phone in which was using google messages. I need to structure that text, classify it, and label anything pertaining to or relevant as evidence in an investigation that I am assisting with for a discrimination case. I am trying to use BERT model and pandas, I just can't get it to accurately determine the right sentiment such as "vulgar,moraley improper,unethical,unprofessional,etc". Any help is appreciated
Hi,Can you also explain this in handwritten text please? I don't know how to apply that to him
Hello thank you for this, and I have question does imageclassification dont need to be annotate?
Hey, by the way yolov8 image classification works, your 'annotations' are the names of the directories containing your images. Take a look at my file structure in the video. 💪🙌
Hello, your videos are very helpful. I would like to ask you if you did before a video concerning object tracking and counting based on a video.
Hey, one of my previous videos is about object tracking using deep sort, check it out! 🙌
@@ComputerVisionEngineer I will. Thank you.
Great video, I would like to ask you how to use it to predict on a large dataset,
Hey Mohamed, the last chapter is about how to use the model to make predictions! 💪🙌
Sir how to get f1 score precision fp tp in yolov8 classification
python version 3.10 was released in 2021, since then its advisable to use this version or above, but you use 3.8. I am not able to finish most of the intermediate to advanced tutorials. Is it because of version , because after thorough internet and documentation search, still not able to find out why image format error is shown by ultralytics. Or is it because of error in the data source.
Hi, yes agreed, using the most recent Python version is preferable. Still, the error you mention, is unlikely to be produced by using Python 3.8.
Hello sir, I have trained my model on a custom dataset having 2 classes, it works fine when I predict an image related to trained classes but whenever I use a random image it predicts between these two classes. How to tackle this situation?
Hey, you could tackle that situacion by looking at the confidence score of the predicted class. If the confidence score is lower than a given threshold (0.80 for example) you classify the image as unknown.
Hello, thanks for sharing great information. I am curious to know about Face emotion recognition using yolo v8. Can you please help me with same ?
Hey, I will try to make a video about it! 💪🙌
Thx!
waiting for pose detection on yolov8! i wanna make a fall detection when yolov8 release pose feature.
🙌 Yeah I am waiting for pose detection on yolov8 too! 😃💪
@@ComputerVisionEngineer is out! plz make a fall person detector!
@@mariocuezzo8027 😃coooooool! Thanks for the heads up! I will definitely make a video about it soon!💪
do i need to create file for config?
# Use the model
results = model.train(data=DATA_DIR, epochs=1, imgsz=64)
this line is not working properly
Thx u!!
Do u have any idea to use YOLOv8 with AWS lambda? I'm out of idea right now
😊 You are welcome! Do you want to use yolov8 from a lambda function? I guess the package is too large to import it through a layer, have you tried with an EFS? Attaching an EFS and installing all the python packages there is a quick fix for using massive python packages in a lambda function. 💪💪
@@ComputerVisionEngineer Yes! it is too large for import layer
I've never used EFS before; do you have any tutorials or something? I will appreciate it a lot.
I do! this is from a could computing channel I used to make: th-cam.com/video/YYzE4ZhWTA4/w-d-xo.html and th-cam.com/video/22c4Ivhw4vg/w-d-xo.html. Enjoy and good luck! 🙌💪
@@ComputerVisionEngineer HI! I'm back. I already try it with serverless framework, create and mount it.
You install python packages by Ec2 right? What if install python package by lambda
We can do it or not?(it gonna work well with my pipeline)
Thx u
Hi Felipe, i’m quite confused in best.pt & last.pt in testing for the final evaluation. Because my best.pt has a higher accuracy than last.pt in training, but when I test the model to the unseen data the last.pt has a higher accuracy than the best.pt advance Thank you for the response, cheers
best.pt is the 'best' model you trained during the training process, best under some criteria which is usually minimum loss or maximum accuracy. last.pt is the model you trained at the end of the training process. It is up to you which one you choose to make your inferences. The 'best' model during training doesn't mean it is the best model to deal with unseen data, as it happened in your case. I usually use last.pt, but it is up to you the one you choose. 🙌
Using last.pt is a bad practice as the model might've overfitted on the data, the best.pt is the one where the validation loss is, minimum implying good performance on unseen data@@ComputerVisionEngineer
please explain how to find f1 score,precision callback etcc,pls bro
Hey Felipe, how do we reuse the model we trained on another data set?
Hey, what do you mean with 'reuse the model'?
@@ComputerVisionEngineer so we've trained it but then how do we use this on a validation set of images?
Wonderful tutorial, Can anyone tell how to print the class with highest prob instead of printing all of them
names_dict = results[0].names
for result in results:
probs = result.probs # Probs object for classification outputs
print(names_dict[np.argmax(probs.data.tolist())])
Hi, i get this error when i run probs line
AttributeError: 'Probs' object has no attribute 'tolist'. See valid attributes below.
pleasehelp me solve it also tell me how to calculate precision and recall and f1 score for this model
It may be the ultralytics package version, try to use the same one I use in the video.
2 months is too late, i get it but it's for others who are facing the same issue: you can do it this way: results[0].probs.numpy() ig the tolist method doesn't exist, or something, idk it didn't work for me either, using the same version of the libraries would help actually, also thanks a lot to this chad for making this video.
Firstly, thank you for making this great video, but it seemed that i have some proplems when i start train my dataset. I follow your video and make my own dataset, but when i start train whatever in terminal or python, it will have problem that ''FileNotFoundError''error happened. I have spent almost all night to fix it, but it seemed that still not get fixed. I will be much appreciated that if you can help me. (Im sured that my dataset format is not wrong and i also input the right data path)
and i also find that you dont make a new yaml to put like classes and nc.what im using is offical code so i was wonder that if there might be some placed need to be edited?
hey, would you please copy paste the error message you get?
@@ComputerVisionEngineer ok!
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\py\Anaconda3\envs\sdsd_torch\lib
unpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\py\Anaconda3\envs\sdsd_torch\lib
unpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\py\Anaconda3\envs\sdsd_torch\Scripts\yolo.exe\__main__.py", line 7, in
File "D:\py\Anaconda3\envs\sdsd_torch\lib\site-packages\ultralytics\yolo\cfg\__init__.py", line 391, in entrypoint
getattr(model, mode)(**overrides) # default args from model
File "D:\py\Anaconda3\envs\sdsd_torch\lib\site-packages\ultralytics\yolo\engine\model.py", line 365, in train
self.trainer = TASK_MAP[self.task][1](overrides=overrides, _callbacks=self.callbacks)
File "D:\py\Anaconda3\envs\sdsd_torch\lib\site-packages\ultralytics\yolo\v8\classify\train.py", line 21, in __init__
super().__init__(cfg, overrides, _callbacks)
File "D:\py\Anaconda3\envs\sdsd_torch\lib\site-packages\ultralytics\yolo\engine\trainer.py", line 126, in __init__
raise RuntimeError(emojis(f"Dataset '{clean_url(self.args.data)}' error ❌ {e}")) from e
RuntimeError: Dataset ''D:\ultralytics-main\data\seed_dataset'' error [WinError 123] : "D:\\ultralytics-main\\datasets\\'D:\\ultralytics-main\\data\\seed_dataset'"
thank for your reply
@@1ron8orn in your config file, are you setting the absolute path to your data?
@@ComputerVisionEngineer yes,but i also try relative path. It also get wrong
"Hello, I have a problem. When I run it, I get a message that I don't have Ultralytics installed: 'No module named 'ultralytics''. However, I have installed it."
Hey Carlos, are you using a virtual environment? make sure you are running the script with the same Python interpreter from the virtual environment where you installed the package. 🙌
Sir how to get f1 score precision fp and positive points sir not showing in matrix and results
You are running on CPU or GPU?
Hey, in my local environment I am running the code on CPU. 💪
@@ComputerVisionEngineer Thanks
@@ComputerVisionEngineer If using CPU, does it automatically take the graphics card or write a code line to trigger graphics card computation.
@@mindchants5646 In both cases, CPU or GPU, It should detect it automatically, it should not require any extra setting.
@@ComputerVisionEngineer For some reason, the video frame slows down when I process any video through any CV operations. Even a simple blur operation slows down the output and the frame rate of the processed video is lower than the original video.
I hope you can help me. Next time I ask you how to print precision,f1 and recall in yolo8
Do you need help printing metrics in yolov8?
Yes I need that in
In yolo8 classification
Hello sir you are doing an an Amazing Job, great channel information ❤
I am struggling with this one project i been working on so i was hoping if you can help me with it?
🥰 Thank you for your support, Moiz! Tell me, what is the project are you struggling with?
@@ComputerVisionEngineer so i have this project where i took picture of different kinds of rice and now I’m struggling to write the machine vision code for it.
The code is basically to detect 3 different defects in the rice.
1)Broken Rice
2) Discoloured Rice
3)Chalky Rice
If you can share me your email or discord i can message you personally
@@moizahmedkazi2225 take a look at the about section for the channel's discord
@@ComputerVisionEngineer the link is invalid sir
@@moizahmedkazi2225 oh thanks for noticing it, it is updated now! here you go discord.gg/uKc5TtCvaT
tanya pada tutorial ini apakah dataset tidak menggunakan pelabelan seperti sebelumnya?
asked in this tutorial whether the dataset does not use labeling as before?
Hey, in this video we use a labeled dataset. It is a weather dataset comprised of 4 categories. 🙌
Sorry sir, so that's for the label to go in folder 4 weather so
nalla ve irukka maata da nee. kindly translate it to english
🙂🙂🙂
legend exists 🥲🥲
😄🙌