Ultralytics YOLO27: Join the waitlist.
License YOLO
Ultralytics YOLO

Extracting outputs from Ultralytics YOLOv8

Learn how to extract bounding boxes, masks, keypoints, and class probabilities from Ultralytics YOLOv8 Results objects and use them in your own Python code.

Nuvola LadiNuvola Ladi3 min read

Listen to this article

Extracting prediction outputs from Ultralytics YOLOv8

Ultralytics YOLOv8 is a widely used computer vision model for tasks like object detection, segmentation, and tracking. Whether you're a seasoned developer or a beginner in artificial intelligence (AI), understanding how to effectively extract outputs from YOLOv8 can significantly enhance your projects. This blog post walks through the practical steps to extract and use results from the YOLOv8 model.

Setting up Ultralytics YOLOv8#

Before diving into the results extraction, it's crucial to have your Ultralytics YOLOv8 model up and running. If you're new, you can watch our previous videos where we cover the basics of setting up and using YOLO models for various computer vision tasks. To start with results extraction, ensure your model is configured correctly:

  1. Model Initialization: Initialize the Ultralytics YOLOv8 model appropriately, making sure you choose the right model configuration that suits your specific needs, be it object detection or more complex tasks like pose estimation.
  2. Running Inference: Input your data through the model to perform inference. This process will generate a list of Results objects, one per image or frame, which is your key to accessing all detection data.

Understanding the results object#

Each Results object in Ultralytics YOLOv8 contains all the detection data that you need to proceed with your project, including:

  • Bounding Boxes: Use result.boxes to access coordinates of detected objects.
  • Masks and Keypoints: Access segmentation masks and keypoints for pose estimation using result.masks and result.keypoints respectively.
  • Class Probabilities: result.probs holds the class probabilities from classification models, while result.boxes.conf gives the confidence score of each detected box, useful for filtering detections.

Extracting data for custom use#

To use these outputs in your applications, follow these steps:

  1. Convert Data for Processing: If you’re running your model on a GPU, convert the outputs to CPU format using .cpu() for further manipulation.
  2. Accessing Bounding Box Coordinates: Retrieve and manipulate bounding box coordinates directly from the results object. This includes accessing normalized coordinates or specific attributes like width and height.
  3. Handling Classifications: Extract top classifications to utilize class IDs and confidence scores effectively.

Practical application in code#

Transitioning from theory to practice, Nicolai Nielsen demonstrates how to implement these concepts within a custom Python script using Visual Studio Code. The script involves:

  • Setting up a Detection Class: Initialize and configure your Ultralytics YOLOv8 model within a class structure, preparing it for live data input.
  • Extracting Results: Run the detection and extract bounding boxes, masks, and classifications directly from the results object.
  • Utilizing Outputs: Convert results into usable formats like JSON or CSV, or use them directly to draw bounding boxes on images or video streams.

Visualization and beyond#

While extracting raw data is crucial, visualizing these detections can provide immediate insights into the model's performance:

  • Drawing Rectangles: Use bounding box data to draw rectangles around detected objects in image or video outputs.
  • Direct Plotting: Use the built-in result.plot() method to visualize detections without additional coding.

Expanding your AI toolkit with Ultralytics YOLOv8#

Mastering Ultralytics YOLOv8 output extraction not only boosts your project’s capabilities but also deepens your understanding of object detection systems.

By following these steps, you can tailor Ultralytics YOLOv8 detections to your specific needs, whether in developing advanced AI-driven applications or conducting robust data analysis.

Stay tuned for more tutorials on Ultralytics YOLOv8 and other AI technologies. Join our community to stay up to date with all the latest developments as well as check out our docs to learn more!

Watch the full video!

Written by

Nuvola Ladi
Nuvola Ladi

Digital Content Manager · Ultralytics

Nuvola Ladi is a Digital Content Manager at Ultralytics, where she creates content covering vision AI and Ultralytics YOLO and represents the company at industry events such as the PyTorch Conference 2025. Based in Spain, she holds a Master's degree in Visual and Digital Media from IE University. Before joining Ultralytics, she held roles at organizations including XVA Gallery & Hotel and Rolex.

Comments

Ask a question, share your results, or help someone else.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning