YOLOv8 is a cutting-edge object detection model developed by Ultralytics that builds upon the success of previous YOLO versions. For more information, see its GitHub repository and documentation.
Install the package using pip:
pip install ultralytics
For alternative installation methods including Conda and Docker, please refer to the Quickstart Guide.
Run object detection from the command line:
yolo predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
Additional parameters can be specified:
yolo predict model=yolov8n.pt source='image.jpg' imgsz=640 conf=0.25
Use YOLOv8 in your Python applications:
from ultralytics import YOLO
# Load a pretrained model
model = YOLO("yolov8n.pt")
# Perform detection
results = model("path/to/image.jpg")
# Display results
results[0].show()
# Export model to ONNX format
model.export(format="onnx")
YOLOv8 comes in several sizes with different performance characteristics:
Model | mAPval | CPU Speed (ms) | Params (M) | FLOPs (B) |
---|---|---|---|---|
YOLOv8n | 37.3 | 80.4 | 3.2 | 8.7 |
YOLOv8s | 44.9 | 128.4 | 11.2 | 28.6 |
YOLOv8m | 50.2 | 234.7 | 25.9 | 78.9 |
YOLOv8l | 52.9 | 375.2 | 43.7 | 165.2 |
YOLOv8x | 53.9 | 479.1 | 68.2 | 257.8 |
To deploy YOLOv8 as a service:
model.export(format="onnx")
Set up an inference server using FastAPI or similar framework
Create endpoint for processing requests:
@app.post("/predict")
async def predict(image: UploadFile = File(...)):
results = model(image.file)
return {"detections": results[0].boxes.data.tolist()}