CV / YOLO-World

YOLO-World

Change detection categories at runtime with English natural-language prompts without rebuilding the model.

4 次下载
精度
INT8 detector / FP16 text encoder

选择你正在使用的设备,设置指南和文档将相应更新。

快速开始

部署
sudo docker run --rm --privileged -p 8000:8000 \
  -v /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-yolo_world:latest \
  python3 web_detection.py --platform rk3576 \
  --model_path /app/model/yolo_world_v2s_i8.rknn \
  --text_model /app/model/clip_text_fp16.rknn \
  --text_features /app/model/coco_text_outp.npy \
  --vocab_path /app/model/clip_vocab.txt --class_path /app/model/detect_classes.txt \
  --camera_id -1 --host 0.0.0.0 --port 8000

REST API

使用 REST API 进行推理。复制以下命令。

Curl
curl http://localhost:8080/v1/chat/completions -d '{
  "model": "yolo-world-rknn",
  "messages": [{"role": "user", "content": "Hello"}]
}'
Python
import requests

resp = requests.post(
    "http://localhost:8080/v1/chat/completions",
    json={"model": "yolo-world-rknn", "messages": [{"role": "user", "content": "Hello"}]},
)
print(resp.json())

模型详情

在 reComputer RK3576 和 RK3588 上运行 YOLO-World

该项目提供来自 reComputer-RK-CV 的开放词汇检测。INT8 YOLO-World 检测器和 FP16 CLIP 文本编码器都在 NPU 上运行,因此无需重新构建检测器即可更改检测类别。

内置 CLIP 模型主要使用英文训练。建议使用 personred bustraffic light 等简短英文名词短语。

模型信息

组件文件
检测器/app/model/yolo_world_v2s_i8.rknn
文本编码器/app/model/clip_text_fp16.rknn
初始 COCO 特征/app/model/coco_text_outp.npy
BPE 词表/app/model/clip_vocab.txt
默认标签/app/model/detect_classes.txt

运行服务

使用与开发板匹配的镜像,并将 --platform 设置为相同的值。

RK3576

bash
sudo docker run --rm --privileged -p 8000:8000 \
  -v /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-yolo_world:latest \
  python3 web_detection.py --platform rk3576 \
  --model_path /app/model/yolo_world_v2s_i8.rknn \
  --text_model /app/model/clip_text_fp16.rknn \
  --text_features /app/model/coco_text_outp.npy \
  --vocab_path /app/model/clip_vocab.txt \
  --class_path /app/model/detect_classes.txt \
  --video_path /app/video/test.mp4 --host 0.0.0.0 --port 8000

RK3588

bash
sudo docker run --rm --privileged -p 8000:8000 \
  -v /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-yolo_world:latest \
  python3 web_detection.py --platform rk3588 \
  --model_path /app/model/yolo_world_v2s_i8.rknn \
  --text_model /app/model/clip_text_fp16.rknn \
  --text_features /app/model/coco_text_outp.npy \
  --vocab_path /app/model/clip_vocab.txt \
  --class_path /app/model/detect_classes.txt \
  --video_path /app/video/test.mp4 --host 0.0.0.0 --port 8000

打开 http://<BOARD_IP>:8000。使用 --prompts "person|red bus|bicycle" 设置启动提示。支持 1 到 80 个用竖线分隔的非空提示,每个提示会截断为 20 个 CLIP token。

启动参数

参数默认值说明
--platform必填目标 NPU:rk3576rk3588
--model_path必填量化的 YOLO-World 检测器。
--text_modelmodel/clip_text_fp16.rknn用于动态提示的 CLIP 文本编码器。
--text_featuresmodel/coco_text_outp.npy初始 (1,80,512) COCO 特征。
--vocab_pathmodel/clip_vocab.txt离线 CLIP BPE 词表。
--class_path内置 COCO 标签与初始特征行匹配的标签。
--promptsCOCO 80 个类别初始的竖线分隔提示短语。
--video_path循环播放的本地 MP4;优先级高于摄像头。
--camera_id1摄像头索引;-1 表示仅分析模式。
--host / --port0.0.0.0 / 8000服务地址和端口。

提示和预测 API

bash
curl -X POST "http://<BOARD_IP>:8000/api/prompts" \
  -H "Content-Type: application/json" \
  -d '{"text":"person|red bus|traffic light"}'

curl -X POST "http://<BOARD_IP>:8000/api/models/yolo_world/predict" \
  -F "file=@bus.jpg" -F "text=person|bus|red vehicle" \
  -F "conf=0.25" -F "iou=0.45"

text 字段只会为本次预测更改提示;/api/prompts 会更改当前视频流提示。提示嵌入会缓存在内存中。动态嵌入填充检测器固定 80 行文本输入的前几行,填充行在后处理期间会被忽略。

GET /api/prompts 读取当前提示。服务还提供健康检查、阈值配置、MJPEG、视频上传、异步分析、状态、列表和下载端点。离线 BPE 词表意味着运行时不会从 Hugging Face 下载分词器资源。

模型替换约束

检测器和文本编码器是匹配的流水线。替换模型必须保留检测器的 80 行文本特征输入、CLIP 嵌入宽度、兼容的分词方式,以及后处理代码所需的输出布局。

本地构建

bash
docker build -f docker/rk3576/yolo_world.dockerfile \
  -t rk3576-yolo-world:local src/rk3576_yolo_world

docker build -f docker/rk3588/yolo_world.dockerfile \
  -t rk3588-yolo-world:local src/rk3588_yolo_world

输入与输出

Input: image, video frame, or camera frame plus up to 80 prompts. Output: prompt-matched boxes and confidence scores.