Getatlas Ljqm58vu6p
Help CenterUltralytics HubUsing Pre-trained Models for Inference

Using Pre-trained Models for Inference

Last updated September 4, 2024

Using Pre-trained YOLOv8 Models for Inference: Get Started with Object Detection Quickly

Ultralytics Hub provides a wealth of pre-trained YOLOv8 models, ready to perform object detection without the need for extensive training. This guide outlines the steps to leverage these pre-trained models for efficient inference, allowing you to quickly implement object detection capabilities in your projects.

Performing Inference with Pre-trained Models

  • Model Selection: Choose the pre-trained model from Ultralytics Hub that aligns with your object detection task and dataset. Consider factors like dataset, object classes, performance metrics (mAP, speed), and model size.
  • Model Download: Download the pre-trained model weights from the Hub. These weights will typically be in a .pt file format.
  • Library Installation: Ensure you have the Ultralytics library installed: `pip install ultralytics`.
  • Loading the Model: Utilize the Ultralytics library to load the model: `model = torch.hub.load('ultralytics/yolov8', 'yolov8n')`. Replace 'yolov8n' with the name of your chosen pre-trained model.
  • Loading Weights: Load the downloaded weights into the model: `model.load_state_dict(torch.load('path/to/weights.pt'))`.
  • Input Preparation: Prepare your input data in the format expected by the model. This could include images or videos.
  • Inference Execution: Perform inference on your input data: `results = model(image)`.
  • Result Interpretation: Analyze the returned results object, which typically includes bounding box coordinates, class labels, and confidence scores for detected objects.
  • Visualization: Visualize the detected objects on your input data using the Ultralytics library's plotting functions.

Real-world Applications

  • Image Processing: Use pre-trained models for tasks like object detection in photos, image classification, and scene analysis.
  • Video Analysis: Apply pre-trained models to analyze video streams, detect objects in real time, and track objects over time.
  • Robotics and Automation: Integrate pre-trained models into robotic systems for tasks such as object manipulation, autonomous navigation, and anomaly detection.
  • Security and Surveillance: Implement pre-trained models for security applications like intrusion detection, facial recognition, and license plate reading.
Was this article helpful?