Object Detection with Pre-trained Ultralytics YOLOv8 Model | Episode 1
Вставка
- Опубліковано 27 вер 2024
- Welcome to the first episode of our new series on Ultralytics YOLOv8! 🎉 Join Nicolai Nielsen as he delves into the powerful capabilities of the pre-trained YOLOv8 model for object detection. In this video, Nicolai walks you through the core concepts of object detection, the model architecture, and the training pipeline. Witness YOLOv8 in action as it detects and classifies objects in real-time with impressive accuracy and speed.
Key highlights covered in this episode:
- Introduction to object detection and YOLOv8 architecture
- Setting up the YOLOv8 model from the GitHub repository
- Running inference with pre-trained YOLOv8 models on various sources (images, videos, live webcam)
- Understanding the inference speed and accuracy of YOLOv8 compared to other YOLO models
- Exploring the unique features and benefits of YOLOv8, including its flexibility and ease of use
Nicolai also demonstrates how to install YOLOv8 on your local machine, run it from the terminal, and use it in Python scripts for both object detection and segmentation tasks. Discover how YOLOv8's pre-trained models, based on the COCO dataset, can deliver accurate predictions with high confidence scores.
🌟YOLO Vision 2024 (YV24), our annual hybrid Vision AI event is just days away! Happening on 27th September 2024 at Google for Startups Campus, Madrid.! Watch live on:
🔗 UA-cam: • Video
🔗 Bilibili: live.bilibili....
Don't miss out on future episodes where we'll cover custom object detection, tracking, pose estimation, and more! 🚀
📚 Dive deeper into YOLOv8:
- Object Detection with Pre-trained YOLOv8: www.ultralytic...
- Using YOLOv8 for Object Detection and Tracking: www.ultralytic...
- Explore Ultralytics HUB: www.ultralytic...
- Discover YOLOv8: docs.ultralyti...
Subscribe to our channel, like this video, and visit our website for more details on how Ultralytics' cutting-edge AI technology can revolutionize your projects.
#YOLOv8 #Ultralytics #ObjectDetection #ComputerVision #AI #MachineLearning #DeepLearning #RealTimeAI #VisionAI - Наука та технологія
Great intro to YOLOv8, Nicolai! How does the performance of this pre-trained model compare to training a custom model from scratch, especially for more niche or specialized tasks? Do you think there's a significant trade-off in terms of accuracy or flexibility?
Thank you for your kind words! 😊 The performance of a pre-trained YOLOv8 model is generally excellent for a wide range of tasks due to its extensive training on diverse datasets. However, for niche or specialized tasks, training a custom model from scratch can offer better accuracy and flexibility tailored to your specific needs. The trade-off often comes down to the time and computational resources required for training. For more details, you can check out our documentation on training custom models. If you have any specific requirements or encounter issues, feel free to share more details! 🚀
Hello, I just tried the exact same command in this video, however the post process time is 800ms, why does this happen? The inference time is a little longer at 85ms and pre processing time is 1.6ms
Inference time is highly dependent on the imgsz and the model size you are using! The small imgsz will provide better inference speed, or you can utilize nano model for better speed.
i will do a YOLO scripTOP in TD right NOW !! I LOVE U !!! would be cool if you would add a spout memory sharing so somone can have subprocess and read the shared texture with the result in other software with ease
That sounds like an exciting project! Implementing a YOLO script in TouchDesigner (TD) is a great idea. Adding Spout memory sharing for subprocesses to read shared textures in other software would indeed enhance the functionality. Best of luck with your YOLO script development! If you have any technical questions or need assistance, feel free to ask.
Thanks for the great video, dude
Thanks :)
Hello Ultralytics in detection it's only showing the image while it's processing and after that the open cv window closes . I want to view the result of detection in an image not only while processing but after processing aswell. How can I do that
After the image processing is complete, the display window will close, and the resulting output will be saved in the runs directory. You can access and view it from that location.
Thanks
Ultralytics Team!
@Ultralytics What is the difference between predict and detect?
Predict is a mode used for making predictions, while Detect is a specific task supported by Ultralytics.
Thanks,
Ultralytics Team!
@@Ultralytics After inference how do I display the final image with bounding boxes and prediction?
You can use the 'show' argument, i.e. 'yolo predict show=True'
@2:38 why its not detecting the bycicle at top right corner?
Hi there! Since it is occluded, small, and in the corner its harder to detect it. Lowering the detection threshold might help in such scenarios.
The explanation was pretty good 🙂. Can I know which library ( like pytorch (or) OpenCV ) has used in VS Code for detecting objects using webcam.
OpenCV is the library utilized for display purposes, while PyTorch is employed for model inference.
Thanks
Ultralytics Team
It is weird. I am testing YOLOv8 on some security camera's and am not getting a lot of results. They are still images, and not the best quality. But for instance I have a picture with a lot of bikes on it, but it is not detecting them. Only if there is a person on the image it is detected.
Ultralytics pretrained models are trained on the COCO dataset, For your specific use case, you might need to fine-tune the model on a custom dataset i.e. in your case you can fine-tune the model on bike images.
Thanks
This code can be used to detect fire?
Yes, of course, the code will remain the same, but you'll need to utilize a fine-tuned model capable of detecting fire.
Thanks,
Ultralytics Team!
Thanks for this video series, i tried running the same code after git clone ultralytics.. and pip install ultralytics, for me it didnt show any bounding box with label and confidence, in your video you are able to see all the labels and bounding box with only 3 lines of code, can you please tell my why this is the case?
Several factors could be causing the issue:
1. Confirm the correct model weights (e.g., yolov5s.pt) are available in the specified path.
2. Check the YOLOv5 configuration file (yolov5.yaml) for accurate settings.
3. Verify dependencies are installed without version conflicts.
4. Ensure the video path is correct to avoid issues with bounding box display.
5. Double-check code execution for any error messages or warnings.
If the problem persists, Please share additional details by opening a new GitHub Issue in Ultralytics repository for better assistance: github.com/ultralytics/ultralytics/issues
Thanks
what is conf which u have mentioned as conf = 0.4?
In Ultralytics YOLOv8, "conf" typically refers to the confidence threshold. When setting it to 0.4, it means that the model will only consider detections with a confidence score greater than or equal to 0.4. Adjusting this threshold can impact the trade-off between precision and recall in object detection. Thanks!!!
Hello Ultralytics can you tell me how can I return class probability for a object detection task.
Am able to return the conf, cls from boxes method. And probs only works for classification task right.
Yes, the probabilities will only work for image classification tasks. For object detection tasks you can get confidence and class name.
Thanks
Ultralytics Team!
When I run the code I keep getting cv.2 error. The code runs for a few seconds then automatically shuts down and the pop up screen showing what my camera sees doesn't show
Ensure you have installed opencv-python, not opencv-python-headless as it does not allow displaying the output and is developed for embedded devices. You can use the mentioned commands below to fix this issue.
```pip uninstall opencv-python-headless opencv-python```
```pip install opencv-python```
Thanks
@@Ultralytics Thank you solved the problem
We're pleased to hear that your concern has been resolved. Thank you.
Thank you so much for the video. How can i access the video used in this tutorial?
These videos are captured directly from a webcam during recording. You can also download high-quality videos from platforms such as Pexels and Canva.
addition to this code what should i write to get the coordinates (without opencv )of the bounding box and print them in the terminal for live detection
After obtaining the detection results, you can utilize the provided code to showcase bounding boxes in the terminal for live detection.
"""python
from ultralytics import YOLO
model = YOLO('yolov8n.pt')
results = model(source=0, show=True, conf=0.4, save=True)
# Extract bounding boxes, classes, names, and confidences
boxes = results[0].boxes.xyxy.tolist()
classes = results[0].boxes.cls.tolist()
names = results[0].names
confidences = results[0].boxes.conf.tolist()
# Iterate through the results
for box, cls, conf in zip(boxes, classes, confidences):
print(box)
#..... continue according to your need
"""
great explanation!
I am training YOLOv8 for potholes detection and i want to compute the area of the bounding boxes came, how can i compute that area, could you please provide me the code for that?
Thanks for the kind words! 😊 To compute the area of bounding boxes, you can use the formula: `area = width * height`. If you're using the YOLOv8 model, you can extract the bounding box coordinates and calculate the area easily. Here's a simple example:
```python
area = (x2 - x1) * (y2 - y1)
```
For more detailed guidance, check out our documentation docs.ultralytics.com/. If you need further assistance, feel free to ask!
For me, know nothings of coding. Any suggestions videos to set it up?
Hi there! 😊 If you're new to coding and want to set up Ultralytics YOLOv8, I recommend checking out our official documentation and tutorials. They provide step-by-step guides that are beginner-friendly. You can start here: docs.ultralytics.com. Also, keep an eye on our UA-cam channel for more tutorials and walkthroughs. If you run into any issues, feel free to ask for help. Happy learning! 🚀
help me figure out if I decide to use YOLOv8 with pre-trained weights at work to solve computer vision problems in commercial projects, will I have to buy a commercial license from ultralitic? will I be able to use an open license without revealing the source codes of my software? My software uses a model to identify cars and pedestrians on the image in order to find traffic violations.
To utilize Ultralytics YOLOv8 for commercial projects, it's necessary to acquire a license from Ultralytics, which can be obtained through this link: www.ultralytics.com/license
If you prefer not to purchase a commercial license, then you need to make the entire software code open source.
When I write the code above vs code, it gives this error, how can I fix it? "WARNING ⚠ Environment does not support cv2.imshow() or PIL Image.show()
OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
This implies that you'll need to install opencv-python-headless. You can do so using the commands provided below:
pip uninstall opencv-python & pip install opencv-python-headless
Great video thank you! Two questions regarding using Yolov8n for object detection: 1. how are you getting different classes of objects to appear with their own bounding box color? and 2. I cannot get my Detection Threshold slider to allow me to only see high confidence objects to works on my Dash app but not Tkinter. How do I do that?
By default, Ultralytics YOLOv8 code is designed to assign a distinct color to each class for visual clarity.
If you encounter any issues with tknitor, we suggest sharing the detailed problem on our GitHub Issues Section: github.com/ultralytics/ultralytics/issues
Thank you.
Well Done
Thanks :)
great video, keep it up!
Hello!
Thank you for the positive feedback! We're glad you enjoyed the video. If you have any questions or need further information on the topic, feel free to ask.
Regards,
Ultralytics Team!
@@ultralytics-team new bot? nice hope is as good as the Glen GitHub one :)
Hey there!
Thanks for the kind words! We're always striving to improve and provide the best support possible. If you have any questions or need assistance, just let us know! 😊
Source index 1 for webcam?
Source index 1 is typically reserved for external cameras connected to the system, while source index 0 is commonly employed for webcams.
Pretty interesting that it detected the dog bed as a Donut, since the format is very similar
Exactly, the reason for this is feature matching. However, these issues can be resolved through the process of fine-tuning Ultralytics YOLOv8 on your custom dataset.
I installed 'ultralytics' in my google colab. But when I import this function, it shows 'No module named 'ultralytics'' . Why this happens ? I am using AMD graphics in my PC
Hi there! 👋 It sounds like you might be experiencing an issue with the installation of the `ultralytics` package in Google Colab. Here are a few steps to help resolve this: 1. Ensure Installation: Make sure you have installed the package correctly. Run: `python !pip install ultralytics ` 2. Restart Runtime: After installation, restart the Colab runtime to ensure the package is properly loaded. 3. Check Versions: Verify that you are using the latest versions of `ultralytics` and `torch`: `python !pip install --upgrade ultralytics torch ` If the issue persists, please share any error messages or additional details. For more help, check out our documentation docs.ultralytics.com. 😊 Note: The type of graphics card on your PC shouldn't affect Google Colab, as it uses its own cloud-based resources. Happy coding! 🚀
@@Ultralytics Last night it worked. But this morning it is showing
ModuleNotFoundError: No module named 'ultralytics'
Sounds like an environment issue. I would restart your system, pip uninstall ultralytics, and then pip install -U ultralytics to update everything.
great video. i have used a custom model but the accuracy of detection is very low as compared to the pretrained model. is there a way to use the pre-trained model but use it to detect only one class for example people only or cars only?
Yes, you can use mentioned command to detect only single class i.e person or car :)
```yolo detect predict source="path/to/video/file.mp4" classes=[0,2]``` #0 class belongs to person, 2 class belongs to car
Thanks
@@Ultralytics hey it's me again is there a way of obtaining these classes?
like a full list of the objects and their class numbers?
@@kozaTG Yes, you can get the class names and their indexes at: github.com/ultralytics/ultralytics/tree/main/ultralytics/cfg/datasets
Sir we could not able to install ultralytics in visual studio code pls help
To get started, ensure that you have Python installed in Visual Studio Code, possibly through the visual studio code extension. Afterward, you can proceed with the installation of Ultralytics using the following command:
```pip install ultralytics```
Thank you,
Ultralytics Team!
how can ı detecct and count moving and unmoving persons with yolo
You will need to follow mentioned steps below.
a) Annotate the moving and non-moving objects
b) Fine-tune the model to detect the moving & non-moving objects
c) validate and deploy the model
Thanks
Ultralytics Team!
How to open webcam?
You can simply pass source=0 to open a webcam during prediction i.e
```yolo detect predict source=0```
hello, why i cannot detect my webcam? i already follow your guide
Hi there! Let's troubleshoot this together. First, ensure your webcam is properly connected and recognized by your system. Next, make sure you're using the latest versions of `torch` and `ultralytics`. If the issue persists, please share any error messages you're seeing. For more detailed guidance, check our docs: docs.ultralytics.com/guides/streamlit-live-inference/. 😊
great stuff from ultralytics, but could you please do a video on setting up an up to date local dev env? the latest Tensorflow versions are no longer supported, so you can't follow along in a windows native shell, you have to set up a dev env in WSL2, to get gpu support
Great suggestion! Yes we will look into that internally. Thanks
Hello @ultralytics how can i write a condition like if people is detected in this .
If your goal is to exclusively detect people, you can utilize the provided code snippet.
```python
import cv2
import numpy as np
from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator, colors
model = YOLO("yolov8n.pt")
names = model.model.names
cap = cv2.VideoCapture("Path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
while cap.isOpened():
success, im0 = cap.read()
if success:
results = model.predict(im0, show=False)
boxes = results[0].boxes.xyxy.cpu().tolist()
clss = results[0].boxes.cls.cpu().tolist()
annotator = Annotator(im0, line_width=3, example=names)
if boxes is not None:
for box, cls in zip(boxes, clss):
if names[int(cls)] == "person": # Check if person class is detected
annotator.box_label(box, color=(255, 144, 31), label=names[int(cls)])
if cv2.waitKey(1) & 0xFF == ord('q'):
break
continue
print("Video frame is empty or video processing has been successfully completed.")
break
cap.release()
video_writer.release()
cv2.destroyAllWindows()
```
Can it be run on Google Colab GPU?
Yes you can run the Ultralytics YOLOv8 in Google Colab Pro, by following our official notebook: github.com/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb
How about on the free version of Google Colab?
@@ifeanyiidiaye1889 YOLOv8 notebooks can be executed in the free version of Google Colab.
Thanks
Can it also run on CPU?
Yes you can run the Ultralytics YOLOv8 in Google Colab Pro, by following our official notebook: github.com/ultralytics/ultralytics/blob/main/examples/tutorial.ipynb
What about on the free version of Google Colab?
On free version, it will also work.
Thanks
is it for videos only? can I use it for photos?
You can perform object detection on both photos and videos!
@@Ultralytics great, thanks! will try...
You're welcome! If you need any help, feel free to ask. Happy detecting! 🚀
How to run ultralytics on GPU?
To utilize GPU acceleration, simply specify `device=0` as an argument when running the model. For a more comprehensive understanding, please refer to the Ultralytics Documentation available at: docs.ultralytics.com/tasks/detect/#predict
I can't install. It is so complicated.
Can you share the error logs? In general, you can install ultralytics package with command mentioned below.
```pip install ultralytics```
File "...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\ultralytics\data\loaders.py", line 53, in __init__
s = eval(s) if s.isnumeric() else s # i.e. s = '0' local webcam
AttributeError: 'NoneType' object has no attribute 'isnumeric'
I keep getting this error while trying to use youtube data for the detections, can anyone help me? Thanks!
Please raise a bug report directly on the repo for support with this.
How can I create an excel or database from the results of the detection?
For technical queries, feel free to post in our GitHub Issue Section or join the community discussion.
GitHub Issues: github.com/ultralytics/ultralytics/issues/new/choose
Discussion: github.com/orgs/ultralytics/discussions
This series looks lit!!! YOLOv8 seems like a game-changer, but how adaptable is it for detecting less common objects or ones not in the training data? Any tips on customizing it for super niche applications? Can't wait for more episodes!!!
Thanks for the enthusiasm! YOLOv8 is indeed a game-changer! For detecting less common objects or those not in the training data, you can customize YOLOv8 by training it on your own dataset. This involves collecting and annotating images of the specific objects you want to detect.
Here's a quick tip: Use tools like Roboflow docs.ultralytics.com/integrations/roboflow/ for dataset management and annotation. Then, follow our guide on training custom datasets docs.ultralytics.com/guides/object-counting/ to get started.
Stay tuned for more episodes! 🚀
Hey Nicolai, great intro to YOLOv8! Quick question: How well does this model handle detecting objects in low-light or high-noise environments? Would love to hear your thoughts on its robustness in real-world scenarios.?
Hey there! YOLOv8 is quite robust and performs well in various conditions, including low-light and high-noise environments. However, its performance can still be affected by extreme conditions. For best results, consider using data augmentation techniques during training to simulate these scenarios. You can find more details in our documentation docs.ultralytics.com/. 😊
I 😍 YOLOv8!
Hello!
Thank you so much for your enthusiasm and support! We're thrilled to hear that you love YOLOv8. We're constantly working hard to improve and expand the capabilities of our models to provide the best possible performance for everyone.
Thanks!
Ultralytics Team!
Hello! We're thrilled to hear that you love YOLOv8! It's packed with advanced features and optimizations to make object detection more efficient and accurate. If you have any questions or need tips on how to get the most out of it, feel free to ask.
Regards,
Ultralytics Team!