Muhammad-Shahin-CS
commited on
Commit
·
d869a8f
1
Parent(s):
ff86e4a
Add README.md with usage instructions and model details
Browse files
README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# YOLOv8
|
| 2 |
+
|
| 3 |
+
This repository contains the YOLOv8 model weights (`yolov8n.pt`) for object detection. YOLOv8 is an advanced version of the YOLO (You Only Look Once) series of real-time object detection models.
|
| 4 |
+
|
| 5 |
+
## Usage
|
| 6 |
+
|
| 7 |
+
To use this model for object detection, follow these steps:
|
| 8 |
+
|
| 9 |
+
### Installation
|
| 10 |
+
|
| 11 |
+
Install the necessary dependencies:
|
| 12 |
+
```bash
|
| 13 |
+
pip install ultralytics
|
| 14 |
+
pip install opencv-python
|
| 15 |
+
|
| 16 |
+
import cv2
|
| 17 |
+
from ultralytics import YOLO
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# code for performing object detection
|
| 21 |
+
def detect_objects(model_path, image_path1, image_path2):
|
| 22 |
+
|
| 23 |
+
# Read images
|
| 24 |
+
input_image1 = cv2.imread(image_path1)
|
| 25 |
+
input_image2 = cv2.imread(image_path2)
|
| 26 |
+
|
| 27 |
+
# Load a model
|
| 28 |
+
model = YOLO(model_path)
|
| 29 |
+
|
| 30 |
+
# Run batched inference on a list of images
|
| 31 |
+
results = model([input_image1, input_image2]) # return a list of Results objects
|
| 32 |
+
|
| 33 |
+
# Process results list
|
| 34 |
+
for result in results:
|
| 35 |
+
boxes = result.boxes # Boxes object for bounding box outputs
|
| 36 |
+
labels = result.cls # labels object for detceted classes outputs
|
| 37 |
+
probs = result.probs # Probs object for classification outputs
|
| 38 |
+
result.show() # display to screen
|
| 39 |
+
result.save(filename="result.jpg") # save to disk
|
| 40 |
+
|
| 41 |
+
# Example usage
|
| 42 |
+
# file paths
|
| 43 |
+
model_path = 'YOLOv8\yolov8n.pt'
|
| 44 |
+
image_path1 = "path_to_your_image.jpg"
|
| 45 |
+
image_path2 = "path_to_your_image.jpg"
|
| 46 |
+
detect_objects(model_path, image_path1, image_path2)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
Model Details
|
| 52 |
+
Model Name: YOLOv8n
|
| 53 |
+
Framework: PyTorch
|
| 54 |
+
Architecture: YOLOv8
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@article{YOLOv8,
|
| 58 |
+
title={YOLOv8: Improved Object Detection with Enhanced Performance},
|
| 59 |
+
author={Muhammad Shahin},
|
| 60 |
+
journal={Hugging Face Models},
|
| 61 |
+
year={2024},
|
| 62 |
+
url={link_to_your_huggingface_model}
|
| 63 |
+
}
|