YOLOv8 is a state-of-the-art object detection and image segmentation model created by Ultralytics, the developers of YOLOv5. YOLOv8, launched on January 10, 2023, features:
We benchmarked YOLOv8 on Roboflow 100, an object detection benchmark that analyzes the performance of a model in task-specific domains. Roboflow 100 is a method of effectively assessing the extent to which a model can generalize across different problems.
We found that YOLOv8 scored a 80.2% mAP score on Roboflow 100, compared to 73.5% mean score on YOLOv5. This shows that YOLOv8 is significantly better at domain-specific tasks than Ultralytics’ YOLOv5 predecessor. We compared YOLOv5s and YOLOv8 in this analysis.
(The table above is sourced from the official YOLOv8 repository).
First, install Inference:
pip install inference
To try a demo with a model trained on the Microsoft COCO dataset, use:
import inference
model = inference.load_roboflow_model("yolov8n-640")
results = model.infer(image="YOUR_IMAGE.jpg")
Above, replace:
YOUR_IMAGE.jpg
with the path to your image.You can also run fine-tuned models with Inference.
Retrieve your Roboflow API key and save it in an environment variable called ROBOFLOW_API_KEY
:
export ROBOFLOW_API_KEY="your-api-key"
To use your model, run the following code:
import inference
model = inference.load_roboflow_model("model-name/version")
results = model.infer(image="YOUR_IMAGE.jpg")
Above, replace:
YOUR_IMAGE.jpg
with the path to your image.model_id/version
with the YOLOv8 model ID and version you want to use. Learn how to retrieve your model and version ID.