深圳Yolo 视觉
深圳
立即加入
词汇表

检测头

了解检测头在目标检测中的关键作用,它能够优化特征图,从而精确地确定目标位置和类别。

A detection head acts as the final decision-making layer in an object detection neural network architecture. While the earlier layers of the model are responsible for understanding the shapes, textures, and features within an image, the detection head is the specific component that interprets this information to predict exactly what objects are present and where they are located. It transforms the abstract, high-level data produced by the feature extractor into actionable results, typically outputting a set of bounding boxes enclosing identified objects along with their corresponding class labels and confidence scores.

区分头部与脊柱及颈部

To fully grasp the function of a detection head, it is helpful to visualize modern detectors as being composed of three primary stages, each serving a distinct purpose in the computer vision (CV) pipeline:

  • Backbone: This is the initial part of the network, often a Convolutional Neural Network (CNN) like ResNet or CSPNet. It processes the raw input image to create feature maps that represent visual patterns.
  • Neck: Sitting between the backbone and the head, the neck refines and combines features from different scales. Architectures like the Feature Pyramid Network (FPN) ensure the model can detect objects of varying sizes by aggregating context.
  • Head: The final component that consumes the refined features from the neck. It performs the actual task of classification (what is it?) and regression (where is it?).

进化:锚点式与无锚点式

The design of detection heads has evolved significantly to improve speed and accuracy, particularly with the transition from traditional methods to modern real-time inference models.

  • 锚点式检测器:传统 单阶段目标检测器依赖 预定义锚框——即多种尺寸的固定参考形状。检测器会预测如何拉伸或移动这些锚点以适配目标。该方法在Faster R-CNN的基础研究中 有详细阐述。
  • Anchor-Free Heads: State-of-the-art models, including the latest YOLO26, utilize anchor-free detectors. These heads predict object centers and dimensions directly from the pixels in the feature maps, eliminating the need for manual anchor tuning. This simplifies the architecture and enhances the model's ability to generalize to novel object shapes, a technique often associated with Fully Convolutional One-Stage Object Detection (FCOS).

实际应用

The precision of the detection head is critical for deploying artificial intelligence (AI) in safety-critical and industrial environments. Users can easily annotate data and train these specialized heads using the Ultralytics Platform.

  • 自动驾驶: 汽车人工智能领域,检测头负责 实时区分行人、交通信号灯及其他车辆。高度 优化的检测头确保 推理延迟保持在足够低的水平,使 车辆能够即时响应。
  • 医学诊断: 在医学影像分析中,检测头经过精细调校,用于定位磁共振成像扫描中的肿瘤等异常病灶。回归分支必须具备极高精度,以勾勒病变的精确边界,从而协助医生制定医疗方案

代码示例

The following example demonstrates how to load a YOLO26 model and inspect the output of its detection head. When inference runs, the head processes the image and returns the final boxes containing coordinates and class IDs.

from ultralytics import YOLO

# Load the YOLO26n model (nano version)
model = YOLO("yolo26n.pt")

# Run inference on an image to utilize the detection head
results = model("https://ultralytics.com/images/bus.jpg")

# The detection head outputs are stored in results[0].boxes
for box in results[0].boxes:
    # Print the bounding box coordinates and the predicted class
    print(f"Class: {int(box.cls)}, Coordinates: {box.xywh.numpy()}")

This interaction highlights how the detection head translates complex neural network activations into readable data that developers can use for downstream tasks like object tracking or counting.

加入Ultralytics 社区

加入人工智能的未来。与全球创新者联系、协作和共同成长

立即加入