Skip to content

This project uses the YOLOv8 model to detect objects in a single image and count how many instances of a specific class (e.g., people) are present.

License

Notifications You must be signed in to change notification settings

ectorr01/YOLOv8-Image-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

YOLOv8 Image Detection Project

This project uses the YOLOv8 model to detect objects in a single image and count how many instances of a specific class (e.g., people) are present.

🧾 Description

The script loads a pre-trained YOLOv8 model (yolov8s.pt) and performs object detection on an input image. It identifies all detected objects and counts how many times a specific class appears (e.g., class 0 = 'person').

✅ The model file (yolov8s.pt) will be automatically downloaded the first time you load the model. No need to manually download or place it in your project folder.

Create Virtual Enviroment and activation

cd your_project
python -m venv .venv

/venv/Scripts/activate  - Windows
source /venv/bin/activate - Linux

📦 Dependencies

Make sure you have the following libraries installed:

  • ultralytics: For using the YOLOv8 model.
  • opencv-python (optional): For displaying or saving annotated images.

Install them via pip:

pip install ultralytics opencv-python

📁 Folder Structure

image_detection_project/
│
├── yolov8s.pt              # Pre-trained YOLOv8 model 
├── your_image.png          # Input image for detection
├── yolo.py                 # Main script
└── README.md

🚀 How to Use

  1. Place your image in the same directory as the script.
  2. Run the script:
python yolo.py
  1. The output will show the number of detected objects of a given class (e.g., people).

⚠️ You can change the class index in the code if you want to count different types of objects.

📝 Notes

  • Detected classes are printed in numeric form by default.
  • To get class names (like "person", "car", etc.), use model.names.

About

This project uses the YOLOv8 model to detect objects in a single image and count how many instances of a specific class (e.g., people) are present.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages