π₯A YOLOv8 guide to logging computer vision data with Babylog

In this tutorial, we will learn the following:
How to run inference with a pre-trained YOLOV8 object detection model on a single image
How to log image and prediction data locally using Babylog
How to load the logged binaries and view the logged information
Pre-requisites
For this tutorial, we will need to install the ultralytics and babylog libraries in python. Best is if you setup a virtual environment for this purpose.
pip install babylog
pip install ultralyticsRunning a YOLOV8 model on a sample image
First, we load a sample image and initialize the YOLO detector with a pre-trained model.
from ultralytics import YOLO
import cv2
model = YOLO("yolov8n.pt") # loading a pretrained model YOLOV8 nano model
img = cv2.imread("bus.jpg")Next, we run inference on the downloaded image with YOLO and measure the inference time. Note that we discard the first few runs and average the inference time (latency) over a number of samples.
Finally, we convert the detected bounding box information to the babylog standard.
Logging predictions using babylog
Babylog provides a standard for efficient logging of prediction data: model information, inference statistics, predictions, and raw input images are bundled up into one file in binary format. In this tutorial, we will only log this data locally, but it is possible to log this data directly to the cloud or stream it via tcp. It is also possible to log data at pre-defined intervals. You can find the full list of configuration parameters in an example here. One can log prediction data with Babylog in a few lines of code. For a full list of what you can log, please refer to the documentation.
Viewing the logged information with babylog
We use the LoggedPrediction class to load the logged binary file.
Next, we draw the detected bounding boxes and overlay the detected class labels and confidence scores on the input image.
Finally, we overlay inference statistics and model information on the image, and display the image with imshow using OpenCV. Click here to check the image with the overlayed information.
Try it out yourself!
You can try out this tutorial in a colab notebook. Follow us on LinkedIn and Github for more tutorials!
Last updated