Welcome to the YOLOv8 Human Detection Beginner's Repository – your entry point into the exciting world of object detection! This repository is tailored for beginners, providing a straightforward implementation of YOLOv8 for human detection in images and videos.
User-Friendly Implementation: Designed with simplicity in mind, this repository offers a beginner-friendly implementation of YOLOv8 for human detection. No advanced knowledge of deep learning or computer vision is required to get started.
Pre-trained Model: Start detecting humans right away with our pre-trained YOLOv8 model. The model has been trained on a variety of datasets, created and imported from Roboflow, to ensure versatility in different scenarios.
Minimal Dependencies: We've kept the dependencies minimal to make it easy for beginners to set up the environment and start using the human detection model without any hassle.
Example Code: Explore example code and scripts to understand how to integrate the YOLOv8 model into your own projects. The repository includes two Python notebooks:
training.ipynb
: Use this notebook for training the YOLOv8 model on your custom datasets or additional data.predictions.ipynb
: Utilize this notebook for making predictions and running the trained model on new images or videos.Model Checkpoints:
best.pt
: This file contains the weights of the YOLOv8 model at the epoch where it achieved the best performance during training.last.pt
: Save time and continue training or fine-tuning the model from the point it left off using this file, which contains the weights from the last epoch.Roboflow Integration: Easily create custom datasets for training by leveraging Roboflow. Use their platform to annotate images, manage datasets, and export the data in YOLOv8-compatible format, streamlining the process of preparing your own data for training.
Dataset Specifications:
Dataset Split:
Preprocessing:
Augmentations:
Training Guide:
# Install the Ultralytics library using pip
!pip install ultralytics
# Install the Roboflow library using pip
!pip install roboflow
# Import the Roboflow and YOLO modules
from roboflow import Roboflow
from ultralytics import YOLO
# The 'Roboflow' module is used for working with datasets on the Roboflow platform
# The 'YOLO' module is imported from the 'ultralytics' library, which is used for YOLO object detection tasks
# Import the Roboflow library and create an instance with the provided API key
api_key = "4DcIf06sr4RzL8YOksef"
rf = Roboflow(api_key)
# Access the Roboflow workspace named "lazydevs"
# Access the project named "human-detection" within the workspace
workspace_name = "lazydevs"
project_name = "human-detection"
project = rf.workspace(workspace_name).project(project_name)
# Download the dataset associated with version 4 of the project using YOLOv8 format
# Note: You might want to include a specific version number or method for version selection.
version = 4
form = "yolov8"
dataset = project.version(version).download(form)
# Initialize the YOLO model by loading the pre-trained weights from 'yolov8n.pt'
model = YOLO('yolov8n.pt')
# Train the model with the specified parameters
results = model.train(
data='/kaggle/input/v4-yaml/data.yaml', # Path to the training data YAML file
epochs=150, # Number of training epochs
batch=64, # Batch size for training
imgsz=640, # Input image size
seed=32, # Random seed for reproducibility
optimizer='NAdam', # Optimizer algorithm
weight_decay=1e-4, # Weight decay for regularization
momentum=0.937, # Initial momentum for the optimizer
cos_lr=True, # Use cosine learning rate scheduling
lr0=0.01, # Initial learning rate
lrf=1e-5, # Final learning rate
warmup_epochs=10, # Number of warmup epochs
warmup_momentum=0.5, # Momentum during warm-up epochs
close_mosaic=20, # Parameter for close mosaic augmentation
label_smoothing=0.2, # Label smoothing parameter for regularization
dropout=0.5, # Dropout rate to prevent overfitting
verbose=True # Print verbose training information
)
Follow these steps to train the YOLOv8 model on your custom human detection dataset. Adjust parameters and paths according to your specific requirements.
git clone https://github.com/J3lly-Been/YOLOv8-HumanDetection.git
best.pt
and last.pt
for different scenarios, such as starting from the best-performing weights or continuing training.This repository is open to contributions from the beginner community. If you have ideas to improve simplicity, clarity, or add new features suitable for beginners, feel free to submit your contributions through issues or pull requests.
Embark on your journey into human detection with YOLOv8 using this beginner-friendly repository. Start detecting humans in no time and gain hands-on experience with object detection!