Object Detection In 5 Minutes YOLOv8 β€” Computer Vision

Object Detection In 5 Minutes YOLOv8 β€” Computer Vision

Play this article

In this article, you learn how to create an Object detection model in just 5 minutes using the YOLOv8 model.

Now let’s get started πŸ’₯

What Is YOLOv8

YOLOv8 is a real-time object detection model developed by Ultralytics company. This is a new family member YOLO. After a long time of research and hard work company build the best Object detection, segmentation, and classification model in the world. The Company goal is to make AI everyone.

Why You Use YoloV8

At this time best computer vision model is available on earth. It’s open-source and beginner friendly. The best thing about this model is it’s a community, whatever you have a problem you found instant answers because it’s a very active community.

How To Use YOLOv8

You can use YOLOv8 for the PyCharm environment β€” the first step is to install YOLOv8 package and then go to write code in PyCharm

A new version of YOLOv8 provides both, a command line interface (CLI) and Python SDK for performing training, validation, and inference. But this time I am only using the pre-trained model and detecting objects.

Install the Ultralytics package for your terminal.πŸ’₯

# Install the ultralytics package and it automatically installs the latest version

pip install ultralytics

Write Code In PyCharm

After the download is complete. And now the main exciting part comes from is 4 lines of code to complete your Object Detection project.

Open your PyCharm IDE and create a new Python file. Write this code below.

from ultralytics import YOLO

YOLO_MODEL_PATH = r"C:\Users\hiwhy\OneDrive\Documents\Blog_post\YOLO-FAMILY\YOLOv8-Article\yolov8s.pt"


model.predict(source="0", show=True,conf=0.80)

Understand Above Code What I Write

Writing without understanding code is like Gambling. You are a Computer Vision developer, not a Gambler. πŸ™…πŸ»

Now let’s understand code! πŸ’₯

First Line β€” I import the Ultralytics package because i am using the YOLOv8 model.

from ultralytics import YOLO

Second Line β€” Load pre-trained model.πŸ€–

# Path specify which area to download the YOLO model. 

YOLO_MODEL_PATH = r"C:\Users\hiwhy\OneDrive\Documents\Blog_post\YOLO-FAMILY\YOLOv8-Article\yolov8s.pt"


The Third Step β€” is to use predict( ) function in the YOLOv8 model.

# source: video file path or 0 mean access my webcam
# show: True Display the output or False mean doesn't display.
# conf: It is a confidence level specified. if above the conf level then draw the object.
# save: if it's specified to True mean save this output locally. and if false means don't save.

model.predict(source='demo_video.mp4',show=True, conf=0.60,save=True) # Using video to detect object.

# OR
# model.predict(source="0", show=True,conf=0.60,save=True) acess webcam and detect object.

In Summary

  • YoloV8 is a very fast and accurate model available on earth in object detection.

  • Use this command in your terminal to install this package pip install ultralytics

Thanks for reading! I hope you enjoyed this short article. Now it's time to build your object detection model. If you have any questions, please ask me in the comments below. I will do my best to answer all of your questions. You can also write any suggestions for me.