Skip to content

Latest commit

 

History

History
120 lines (88 loc) · 4.94 KB

README.md

File metadata and controls

120 lines (88 loc) · 4.94 KB

YOLOv8

YOLOv8 Object Detection & Image Segmentation Implementation (Easy Steps)

Object Detection & Segmentation Concept

Functions

  • Object Detection
  • Image Segmentation
  • Document

Download Yolov8 Weights

  • Download the pretrained YOLOv8 weights or you can use your own custom trained weights, and paste it in the main folder.
Object Detection Models

| YOLOv8n | | YOLOv8s | | YOLOv8m | | YOLOv8l | | YOLOv8x |

Image Segmentation Models

| YOLOv8n-seg | | YOLOv8s-seg | | YOLOv8m-seg | | YOLOv8l-seg | | YOLOv8x-seg |

Implementation

  • Create Conda Environment
conda create –n yolov8 python=3.9
conda activate yolov8

Install

  • Pip install the ultralytics package including all requirements.txt
pip install ultralytics

CLI

  • Run yolov8 directly on Command Line Interface (CLI) with commands mentioned below. It has various hyperparameters and configurations.
 yolo task=detect mode=predict model=yolov8n.pt source=img.jpg         #object detection on image
 yolo task=detect mode=predict model=yolov8n.pt source=1.jpg conf=0.5  # Set the confidence level at 0.5
 yolo task=detect mode=predict model=yolov8n.pt source=1.jpg conf=0.5 show=true     # Show output in real-time
 yolo task=detect mode=predict model=yolov8n.pt source=1.jpg conf=0.5 save_txt=true  # Save the bounding boxes information
 yolo task=detect mode=predict model=yolov8n.pt source=1.jpg conf=0.5 save_crop=true  # Save cropped objects
 yolo task=detect mode=predict model=yolov8n.pt source=1.jpg conf=0.5 save_crop=true hide_labels=true hide_conf=true  #Remove the label and confidence level
 yolo task=detect mode=predict model=yolov8s.pt source=0 #Object Detection on webcam
 yolo task=detect mode=predict model=yolov8s.pt source=video.mp4 show=true     # Object Detection on MP4 Video
 yolo task=detect mode=predict model=yolov8s.pt source='C:\Users\zeeshan\Desktop\yolov8'  #Object Detection on directory 

Main Code Python

  • Use any model and source just uncomment it and run file on conda environment.
from ultralytics import YOLO
#import cv2
#import time
#import os


# Object Detection Models

#model = YOLO("yolov8x.pt")          # Detection ( Extra Large )
#model = YOLO("yolov8l.pt")           # Detection ( Large Model )
#model = YOLO("yolov8m.pt")          # Detection ( Medium Model)
#model = YOLO("yolov8s.pt")          # Detection ( Small Model )
model = YOLO("yolov8n.pt")          # Detection ( Nano Model  ) 


#Segmentation Model

#model = YOLO("yolov8m-seg.pt")       # Segmentation (Medium Model)

# Predictions for  Directory Folder, videos, images, and webcam

model.predict(source="C:/Users/zeeshan/Downloads/yolov8/Data/Images", show=True, save=True) # Images Directory Folder
#model.predict(source="C:/Users/zeeshan/Desktop/yolov8/Data/Videos", show=True, save=True) # Videos Directory Folder
#model.predict(source= '0', show=True, save=True) # Webcam

#model.info(verbose=True)  '                     # Print model information
#model.export(format="onnx")                    #export model into ONXX

Results

Object Detection

Image Segmentation

References