File size: 2,627 Bytes
e3542a8 d869a8f 423ea98 e3542a8 423ea98 c3c7963 423ea98 c3c7963 bda7331 b60455b bda7331 b60455b c3c7963 d869a8f c3c7963 d869a8f c3c7963 d869a8f bda7331 d869a8f bda7331 d869a8f c3c7963 d869a8f c3c7963 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# YOLOv8
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.
## Documentation
See below for a quickstart installation and usage example, and see the YOLOv8 Docs for full documentation on training, validation, prediction and deployment.
## CLI
YOLOv8 may be used directly in the Command Line Interface (CLI) with a yolo command:
```bash
yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
```
## Python
To use this model for object detection, follow these steps:
```bash
from ultralytics import YOLO
# Load a model
model = YOLO("yolov8n.yaml") # build a new model from scratch
model = YOLO("yolov8n.pt") # load a pretrained model (recommended for training)
# Use the model
model.train(data="coco128.yaml", epochs=3) # train the model
metrics = model.val() # evaluate model performance on the validation set
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
path = model.export(format="onnx") # export the model to ONNX format
```
For more examples and detailed usage instructions, visit the [YOLOv8 Python Docs](https://docs.ultralytics.com/models/yolov8/#usage-examples).
## Example usage
code for performing object detection
```bash
# Install the import necessary dependencies:
pip install ultralytics
pip install opencv-python
import cv2
from ultralytics import YOLO
def detect_objects(model_path, image_path1, image_path2):
# Read images
input_image1 = cv2.imread(image_path1)
input_image2 = cv2.imread(image_path2)
# Load a model
model = YOLO(model_path)
# Run batched inference on a list of images
results = model([input_image1, input_image2]) # return a list of Results objects
# Process results list
for result in results:
boxes = result.boxes # Boxes object for bounding box outputs
labels = result.cls # labels object for detceted classes outputs
probs = result.probs # Probs object for classification outputs
result.show() # display to screen
result.save(filename="result.jpg") # save to disk
# Example usage
model_path = 'YOLOv8\yolov8n.pt'
image_path1 = "path_to_your_image.jpg"
image_path2 = "path_to_your_image.jpg"
detect_objects(model_path, image_path1, image_path2)
```
```bash
@article{YOLOv8,
title={YOLOv8: Improved Object Detection with Enhanced Performance},
author={Muhammad Shahin},
journal={Hugging Face Models},
year={2024},
url={link_to_your_huggingface_model}
}
``` |