Export a custom-trained Ultralytics YOLOv8 model
Train a custom Ultralytics YOLOv8 object detection model in Google Colab, export the trained weights, and run live webcam inference with a few lines of Python.
Nuvola Ladi3 min readListen to this article

Join us as we take a closer look at custom object detection with Ultralytics YOLOv8. In this blog post, we’ll explore the process of training a custom model, exporting the trained weights, and running live inference on a webcam.
Training a custom object detection model#
In our previous video, we covered training an Ultralytics YOLOv8 model on a custom dataset in Google Colab, using a dataset of cups. We saw the training graph steadily improving, with the loss decreasing and the mean average precision (mAP) increasing. Based on this, our custom model can now identify five different types of cups very accurately.
With our custom model trained and ready to go, it's time to explore the next step: exporting the trained weights and running live inference on a webcam.
Model inference is the process of using a trained computer vision model to make predictions or decisions based on new, unseen data. It is when the model uses input data, such as an image, and processes it through its learned parameters and structure. The model then produces an output, such as classification, detection, or segmentation, based on its training task.
In practical terms, inference often involves deploying the trained model into a production environment where it can be used to process real-world data in real time or in batch-processing scenarios.
Exporting and running inference with the trained model#
With the trained model weights downloaded from Colab, we can load them into a Python environment and put our custom model to work.
Using a few lines of code, we can set up a Python script to run live inference on a webcam, capturing real-time footage and detecting different cups. The model identifies cups of various shapes, sizes, and colors, showing how well it handles real-world scenarios.
Fine-tuned models offer several benefits. They can detect, segment, or classify objects that pretrained models may not support. Additionally, they can assist researchers or data scientists in understanding how model architecture performs on real-world datasets.

Fig 1. Nicolai Nielsen outlining how to train a custom model, export the trained weights, and run live inference on a webcam.
Wrapping up#
From training a custom model to exporting the trained weights and running live inference on a webcam, we've seen how Ultralytics YOLOv8 handles the full workflow.
Ready to try custom object detection yourself? Check out Ultralytics Platform and our docs for more information on all things Ultralytics, and join our community to keep up to date on the latest developments!
If you’re curious about exporting custom-trained Ultralytics YOLOv8 models and running inference on a webcam, watch the full video!
Written by
Comments
Ask a question, share your results, or help someone else.










