Real-time Instance Segmentation with YOLOv8: Create Custom Object Detection Models with Webcam
HTML-код
- Опубликовано: 18 июн 2024
- Inside my school and program, I teach you my system to become an AI engineer or freelancer. Life-time access, personal help by me and I will show you exactly how I went from below average student to making $250/hr. Join the High Earner AI Career Program here 👉 www.nicolai-nielsen.com/aicareer (PRICES WILL INCREASE SOON)
You will also get access to all the technical courses inside the program, also the ones I plan to make in the future! Check out the technical courses below 👇
_____________________________________________________________
In this video 📝 we are going to Train and Deploy a YOLOv8 for Custom Instance Segmentation with Webcam in Real-time. First of all, we will train the yolov8 model in google colab on a custom dataset. After training, we will export the training YOLOv8 model and see how to deploy the model and run live inference on a webcam. This can actually run in real-time. You can also check out my YOLOv7 Course where we cover everything from generating a dataset, setting up the model, training, and deployment.
If you enjoyed this video, be sure to press the 👍 button so that I know what content you guys like to see.
_____________________________________________________________
🛠️ Freelance Work: www.nicolai-nielsen.com/nncode
_____________________________________________________________
💻💰🛠️ High Earner AI Career Program: www.nicolai-nielsen.com/aicareer
⚙️ Real-world AI Technical Courses: (www.nicos-school.com)
📗 OpenCV GPU in Python: www.nicos-school.com/p/opencv...
📕 YOLOv7 Object Detection: www.nicos-school.com/p/yolov7...
📒 Transformer & Segmentation: www.nicos-school.com/p/transf...
📙 YOLOv8 Object Tracking: www.nicos-school.com/p/yolov8...
📘 Research Paper Implementation: www.nicos-school.com/p/resear...
📔 CustomGPT: www.nicos-school.com/p/custom...
_____________________________________________________________
📞 Connect with Me:
🌳 linktr.ee/nicolainielsen
🌍 My Website: www.nicolai-nielsen.com/
🤖 GitHub: github.com/niconielsen32
👉 LinkedIn: / nicolaiai
🐦 X/Twitter: / nielsencv_ai
🌆 Instagram: / nicolaihoeirup
_____________________________________________________________
🎮 My Gear (Affiliate links):
💻 Laptop: amzn.to/49LJkTW
🖥️ Desktop PC:
NVIDIA RTX 4090 24GB: amzn.to/3Uc7yAM
Intel I9-14900K: amzn.to/3W4Z5Cb
Motherboard: amzn.to/4aR6wBC
32GB RAM: amzn.to/3Jt2XVR
🖥️ Monitor: amzn.to/4aLP8hh
🖱️ Mouse: amzn.to/3W501GH
⌨️ Keyboard: amzn.to/3xUGz5b
🎙️ Microphone: amzn.to/3w1F1WK
📷 Camera: amzn.to/4b4Ryr9
_____________________________________________________________
Timestamps:
0:00 Intro
0:42 Setup and Dataset
4:35 Train YOLOv8 Model
11:52 Deploying YOLOv8 Model
Tags:
#yolov8 #yolo #instancesegmentation #ultralytics - Наука
Join My AI Career Program
www.nicolai-nielsen.com/aicareer
Enroll in My School and Technical Courses
www.nicos-school.com
how do we want to make detection prediction classs 12:07
appreciate your content, very inspiring!
Thank you so much!
Hey I am using an external camera which is basically a stereo camera. Do you think I can put the camera as a source in the model inference? Note that the stereo camera gives RGBD values instead of RGB. So I have to get the RGB frame for each RGBD frame and then send those frames to the model. I tried it once but due to CUDA issues there was segmentation fault and I could not run it? Any idea how to bypass that?
Hi, I'm using laptop for real time instance segmentation. I already has custom data set pt file.
when I run python file with my best pt files it shows but the fps it's very low.
On your video it only takes 1~2 ms to detect but mine takes about 800ms to detect object. I'm only using CPU and RAM. Does GPU helps less time to detect and increase fps?
appreciate your efforts and content ! can you please provide info about the gpu you're using for inference ?
Hi Nicolai, I have received the following error when trying to perform the live inference using my custom model: "Import "ultralytics.yolo.v8.detect.predict" could not be resolved". I have correctly installed ultralytics as I have been able to import YOLO successfully for this case and others. How can I overcome this issue?
This is awsome work! Thank you very very muchh!!I have a question....do you think i can stream data from a link instead of my webcamera in colab and do the real time segmentation?
thanks a lot. U will prob not be able to run it real-time in colab. But u can download a video from a link and then pass that through the model in colab
@@NicolaiAI Good! Generally does this algorithm supports real time from a stream-link? The source flag will be the link?
Can Yolov8 instance segmentation for product SKU?
Stuck on this line of code: "!yolo task=segment mode=train model=yolov8l-seg.pt data={dataset.location}/data.yaml epochs=30 imgsz=640"
The output error says: "FileNotFoundError:
Dataset '/content/Cup-Detection-v2-3/data.yaml' not found ⚠, missing paths ['/content/datasets/Cup-Detection-v2-3/valid/images'] "
but there is a data.yaml on Cup-Detection-v2-3 folder.
tried to show the path for data='/content/datasets/Cup-Detection-v2-3/valid/images'
but unsuccessful.
Does anyone have a hint?
solved by changing on data.yaml file
from:
test: ../test/images
train: Cup-Detection-v2-3/train/images
val: Cup-Detection-v2-3/valid/images
to:
test: ../test/images
train: /content/Cup-Detection-v2-3/train/images
val: /content/Cup-Detection-v2-3/valid/images
@@dserenini Dude u r awesome !
Hi, what is your GPU? My GPU is kind of weak so I am not sure whether it can get thing done in real-time.
Im using a rtx 4090. It Can run real time on most gpus. U Can always try out the smaller versions of yolo
@@NicolaiAI Thank you, I just check the benchmark comparison and my GPU is terrible compared to yours (Geforce mx330).
For some reason, the prediction file is not getting saved. Can someone let me know what my problem is?
hello when i try to segmentation for dog.jpeg it didnt put square to objects. It showed the same picture without segmentation but wrote the correct output. How can i fix this ?
Do u set show to true?
@@NicolaiAI yes it works well just doesn't show the output image. When i add parameter save = True it saves to different path ("/runs/segment/predict") then i could see the output image. But i dont know why i cant see the output image when i write like yours.
@@EgeSener I’m not sure since im using a webcam as the source in this example. Haven’t tried it with a single image
I tried to get prediction on Yolo v8 using the same command in your python code but got no output
Did u specify all the paths correctly? And maybe try with a single image to start with
I need help. Is it possible to use yolov8 and tensorflow at the same time on my nvidia gpu? Seems like I need cuda 11.2 for tensorflow, but cuda 11.8 for yolov8. I don't know how to get both working together.
Amazing video and nice wallpaper. Where could I find the wallpaper?
Thanks a lot! What wallpaper are u talking about?
@@NicolaiAI The wallpaper at the beginning of the video ~10 secs in to the video you have all 3 monitors up and the wallpapers you have are nice
@@keshawnsmith320 haha i actually think it’s just some standard ones in windows 11
@@NicolaiAI Gotcha makes sense! Also, if you do have a personal laptop is it mac or windows that you use?
@@keshawnsmith320 I’m using Linux on my laptop so kinda have to go for windows laptops. But for anything else and if what I do can run on Mac I’ll go for Mac anyday
Hello sir how can you deploy the counting text inside the video/image?
Hi! What do u mean with counting text?
@@NicolaiAI what i mean sir is that i want to dispay the counted object above the frame of the image or video generated by detection. We can see at the result that every frame it shows the counted object and i want to display it together with the generates images or video frame. Thank you sir.
@@xilite136 if u take a look at my tracking video with Yolov8 u can see how to modify the visualisation
@@NicolaiAI I think this link might be it ruclips.net/video/UYLp0-iOvFc/видео.html
How to crop the segment area from the images?
u can't crop a segmentation mask but you can crop the bounding box in the image around it
I want to work on a similar project but I am doubting how YOLO will be usefull in my case, I want to apply the same technique of detection but instead of random images, I want to train it to detect some pattern in the stock market do you think training it in top of the already treaned yolov8 in this case will be useful ? and also I don't want to use the webcam or any video capturing device but instead taking screenshots from my dektop and act as real time frame detection
Yeah u can definitely try out yolo to start with since it’s easy to setup. For that project it might also be beneficial to train a model from scratch but would require a lot of data depending on how many different patterns
@@NicolaiAI yeah the problem is that the pattern/input of the model will be a video's and I have a very limited amount of data, probably no data augmentation is possible in that case
To predicting stock you might want an API for stock time series and traing on that data to predict prices with huge datasets. Trying to apply object detection and segmentation is a nice project to code, but I would not reccoment to apply it to cualitative analysis which is proven to not produce a nice results at all.
The most important thing about predicting stock is to know what are you doing so you ask the right questions and find the right answers.
You should start learning statistics, and then machine learning. That way you will know what is stochastic behaviour and why you cannot predict random spontaneous events outside your dataset. Any predictable event should be anticipated with a previous pattern event you will find in a feature.
For nvdia-smi
I am getting "command not found" error .can anyone please help.thanks in advance
If u are using Google colab it should work out of the box. Did you change the runtime to gpu?
@@NicolaiAI it works , thanks a lot
Can't find this .ipynb and all other codes...
It’s on my GitHub under neural networks
@@NicolaiAI Not found
Hi i'm getting this error ,
ImportError: cannot import name 'DetectionPredictedClass' from 'ultralytics.yolo.v8.detect.predict' (/usr/local/lib/python3.10/dist-packages/ultralytics/yolo/v8/detect/predict.py)
when I try the code I get this error: im0 = self.annotator.result()
AttributeError: 'NoneType' object has no attribute 'result'
What to do with that? :/
please stop repeating :"we got some really nice results", open your eyes and see all the FALSE positives that the model is showing when you switched on the webcam, i am sure you would see a lot more if you moved the webcam to view different objects
Have u heard about conf, nms, iou?
@@NicolaiAI tried all of them, won't improve results much.
Yolo is defective in its core, did u try it on production? Or only playing with it as a toy?
Of course it improves results if u have a confidence score of 0.4 or 0.8? U can also do tracking on top of it etc. u can also do way more in the training itself or in ur dataset
U mentioned deploying in production? U would never use the standard code and preprocessing from yolo for that and a specific application. And u would also have mentioned tracking then. My advice would be not to use DL in ur case
@@NicolaiAI u think i didnt try all of that? increasing conf value will reduce false positives but will increase FALSE NEGATIVES (your recall and F1 scores will drop), tracking cant do u anything if the actual prediction is wrong (lots and lots of false positives), i trained on more than 18k images for 100s of epochs, the model still can NOT generalize well when seeing new data
After I ran the training code "!yolo task=segment mode=train model=yolov8l-seg.pt data=/content/RV_seg-1/data.yaml epochs=15 imgsz=640".
I had the following error message.
Epoch GPU_mem box_loss seg_loss cls_loss dfl_loss Instances Size
0% 0/82 [00:04
hey did you find the solution