遇见 YOLO26: 下一代视觉 AI。
Ultralytics
返回 Ultralytics 词汇表

CLIP (Contrastive Language-Image Pre-training)

探索 CLIP (对比语言-图像预训练) 以连接视觉与语言。了解它如何实现零样本学习并为 Ultralytics YOLO26 提供支持。

CLIP (Contrastive Language-Image Pre-training) is a revolutionary neural network architecture developed by OpenAI that bridges the gap between visual data and natural language. Unlike traditional computer vision (CV) systems that require labor-intensive data labeling for a fixed set of categories, CLIP learns to understand images by training on millions of image-text pairs collected from the internet. This approach allows the model to perform zero-shot learning, meaning it can identify objects, concepts, or styles it has never explicitly seen during training, simply by reading a text description. By mapping visual and linguistic information into a shared feature space, CLIP serves as a powerful foundation model for a wide variety of downstream tasks without the need for extensive task-specific fine-tuning.

Link to this section架构的工作原理#

The core mechanism of CLIP involves two parallel encoders: an image encoder, typically based on a Vision Transformer (ViT) or a ResNet, and a text Transformer similar to those used in modern large language models (LLMs). Through a process known as contrastive learning, the system is trained to predict which text snippet matches which image within a batch.

在训练期间,模型会优化其参数,以拉近匹配图像-文本对的向量 嵌入,同时推远不匹配的对。这创建了一个多模态 潜在空间,其中“金毛寻回犬”图像的数学表示在空间上位于“一张狗的照片”的文本嵌入附近。通过计算这些向量之间的 余弦相似度,模型可以量化图像与自然语言提示的对应程度,从而实现灵活的 图像分类 和检索。

Link to this section实际应用#

将视觉与语言联系起来的能力使 CLIP 成为现代 AI 应用中的基石技术:

  • 智能 语义搜索:CLIP 允许用户使用复杂的 自然语言处理 (NLP) 查询来搜索大型图像数据库。例如,在 零售业 AI 中,购物者可以搜索“复古花卉夏日连衣裙”并获取视觉上准确的结果,而无需图像带有这些特定的元数据标签。这通常由高性能 向量数据库 提供支持。
  • 生成式 AI 控制:像 Stable Diffusion 这样的模型依赖 CLIP 来解释用户提示并指导生成过程。CLIP 充当评分器,评估生成的视觉输出与文本描述的对齐程度,这对于高质量的 文本转图像 合成至关重要。
  • 开放词汇 目标检测:像 YOLO-World 这样的先进架构集成了 CLIP 嵌入,以根据任意文本输入检测对象。这允许在 医疗保健 AI 等领域进行动态检测,在这些领域中,无需重新训练即可识别新型设备或异常情况是必要的。

Link to this section将 CLIP 特征与 Ultralytics 结合使用#

虽然标准目标检测器仅限于其训练类别,但使用基于 CLIP 的特征可以实现开放词汇检测。以下 Python 代码演示了如何使用 ultralytics 包通过自定义文本提示检测对象:

from ultralytics import YOLOWorld

# Load a pre-trained YOLO-World model utilizing CLIP features
model = YOLOWorld("yolov8s-world.pt")

# Define custom classes using natural language text prompts
model.set_classes(["person wearing sunglasses", "red backpack"])

# Run inference on an image to detect the text-defined objects
results = model.predict("travelers.jpg")

# Display the results
results[0].show()

Link to this section区分相关概念#

区分 CLIP 与其他常见 AI 范式有助于理解其具体用途:

  • CLIP 与 监督学习:传统的监督模型需要对每个类别(例如“猫”、“车”)进行严格的定义和标注示例。CLIP 从网络上的原始文本-图像对中学习,提供了更大的灵活性,并消除了通常通过 Ultralytics Platform 等工具管理的繁琐手动标注瓶颈。
  • CLIP 与 YOLO26:虽然 CLIP 提供了对概念的通用理解,但 YOLO26 是专为速度和精确定位而优化的专业实时目标检测器。CLIP 通常用作特征提取器或零样本分类器,而 YOLO26 是生产环境中高速 实时推理 的引擎。
  • CLIP 与标准对比学习:像 SimCLR 等方法通常比较同一图像的两个增强视图以学习特征。CLIP 将图像与文本描述进行对比,桥接了两个不同的数据模态,而不仅仅是一个。

Explore solutions

Real-time AI that works with your team

机器人技术中的 AI

使用 Ultralytics YOLO 模型为智能机器赋能。机器人技术中的视觉 AI 可推动自主导航、感知、物体跟踪和实时控制。

了解更多
Real-time AI that works with your team

物流中的 AI

使用 Ultralytics YOLO 模型简化物流。视觉 AI 可实现包裹检查、分拣、车辆跟踪和实时仓库安全监控。

了解更多
Real-time AI that works with your team

零售业 AI

使用 Ultralytics YOLO 模型重塑零售业。视觉 AI 推动库存跟踪、货架监控、队列管理和更智能的客户洞察。

了解更多
Real-time AI that works with your team

医疗保健中的 AI

利用 Ultralytics YOLO 模型构建医疗保健解决方案。医疗保健中的视觉 AI 可助力更快速的医学影像分析、更智能的诊断和患者监测。

了解更多
Real-time AI that works with your team

制造业中的 AI

使用 Ultralytics YOLO 模型优化制造业。视觉 AI 推动质量控制、缺陷检测、PPE 合规性和装配线自动化。

了解更多
Real-time AI that works with your operation

汽车中的 AI

将计算机视觉应用于汽车行业,并配合 Ultralytics YOLO 模型。汽车视觉 AI 可提升道路安全、辅助驾驶和车辆自动化,打造更智能的道路。

了解更多
Real-time AI tailored to your operation

农业中的 AI

借助 Ultralytics YOLO 模型,将视觉 AI 引入智慧农业。赋能作物监测、牲畜追踪和精准农业,实现更高、更智能的产量。

了解更多
Real-time AI that works with your team

机器人技术中的 AI

使用 Ultralytics YOLO 模型为智能机器赋能。机器人技术中的视觉 AI 可推动自主导航、感知、物体跟踪和实时控制。

了解更多
Real-time AI that works with your team

物流中的 AI

使用 Ultralytics YOLO 模型简化物流。视觉 AI 可实现包裹检查、分拣、车辆跟踪和实时仓库安全监控。

了解更多
Real-time AI that works with your team

零售业 AI

使用 Ultralytics YOLO 模型重塑零售业。视觉 AI 推动库存跟踪、货架监控、队列管理和更智能的客户洞察。

了解更多
Real-time AI that works with your team

医疗保健中的 AI

利用 Ultralytics YOLO 模型构建医疗保健解决方案。医疗保健中的视觉 AI 可助力更快速的医学影像分析、更智能的诊断和患者监测。

了解更多
Real-time AI that works with your team

制造业中的 AI

使用 Ultralytics YOLO 模型优化制造业。视觉 AI 推动质量控制、缺陷检测、PPE 合规性和装配线自动化。

了解更多
Real-time AI that works with your operation

汽车中的 AI

将计算机视觉应用于汽车行业,并配合 Ultralytics YOLO 模型。汽车视觉 AI 可提升道路安全、辅助驾驶和车辆自动化,打造更智能的道路。

了解更多
Real-time AI tailored to your operation

农业中的 AI

借助 Ultralytics YOLO 模型,将视觉 AI 引入智慧农业。赋能作物监测、牲畜追踪和精准农业,实现更高、更智能的产量。

了解更多
Real-time AI that works with your team

机器人技术中的 AI

使用 Ultralytics YOLO 模型为智能机器赋能。机器人技术中的视觉 AI 可推动自主导航、感知、物体跟踪和实时控制。

了解更多
Real-time AI that works with your team

物流中的 AI

使用 Ultralytics YOLO 模型简化物流。视觉 AI 可实现包裹检查、分拣、车辆跟踪和实时仓库安全监控。

了解更多
Real-time AI that works with your team

零售业 AI

使用 Ultralytics YOLO 模型重塑零售业。视觉 AI 推动库存跟踪、货架监控、队列管理和更智能的客户洞察。

了解更多
Real-time AI that works with your team

医疗保健中的 AI

利用 Ultralytics YOLO 模型构建医疗保健解决方案。医疗保健中的视觉 AI 可助力更快速的医学影像分析、更智能的诊断和患者监测。

了解更多
Real-time AI that works with your team

制造业中的 AI

使用 Ultralytics YOLO 模型优化制造业。视觉 AI 推动质量控制、缺陷检测、PPE 合规性和装配线自动化。

了解更多
Real-time AI that works with your operation

汽车中的 AI

将计算机视觉应用于汽车行业,并配合 Ultralytics YOLO 模型。汽车视觉 AI 可提升道路安全、辅助驾驶和车辆自动化,打造更智能的道路。

了解更多
Real-time AI tailored to your operation

农业中的 AI

借助 Ultralytics YOLO 模型,将视觉 AI 引入智慧农业。赋能作物监测、牲畜追踪和精准农业,实现更高、更智能的产量。

了解更多

让我们一起构建 AI 的未来!

开启你的机器学习未来之旅