RTDETRv2 và YOLOX
Các nhà phát triển xây dựng hệ thống phát hiện đối tượng thời gian thực có thể lựa chọn từ nhiều kiến trúc. Hai kiến trúc đáng chú ý là RTDETRv2 dựa trên Transformer và mạng nơ-ron tích chập (CNN) YOLOX. Cả hai đều thúc đẩy lĩnh vực phát hiện thời gian thực, nhưng áp dụng những cách tiếp cận hoàn toàn khác nhau để nhận diện hình ảnh.
Hướng dẫn này trình bày kiến trúc, các chỉ số hiệu năng và kịch bản triển khai lý tưởng cho cả hai model, đồng thời cho thấy Ultralytics YOLO26 phát triển dựa trên những nền tảng này như thế nào để đạt độ chính xác, hiệu quả và tính dễ sử dụng cao hơn.
RTDETRv2: Transformer phát hiện thời gian thực#
Ra mắt như phiên bản kế nhiệm RT-DETR ban đầu, RTDETRv2 sử dụng kiến trúc Transformer để phát hiện đối tượng thời gian thực. Bằng cách loại bỏ nhu cầu Non-Maximum Suppression (NMS), model đơn giản hóa quy trình inference.
- Tác giả: Wenyu Lv, Yian Zhao, Qinyao Chang, Kui Huang, Guanzhong Wang và Yi Liu
- Tổ chức: Baidu
- Ngày: 2024-07-24
- Liên kết: Bài báo arXiv, GitHub chính thức, Tài liệu
Kiến trúc và thiết kế#
RTDETRv2 dựa vào cơ chế self-attention của Transformer để nắm bắt ngữ cảnh toàn cục trên toàn bộ ảnh, nhờ đó model có thể dự đoán trực tiếp bounding box và xác suất lớp. Các đặc trưng đa tỷ lệ giúp model nhận diện đối tượng nhỏ trong môi trường lộn xộn.
Mặc dù Transformer vượt trội trong việc nắm bắt ngữ cảnh toàn cục, cơ chế self-attention của Transformer tăng theo bình phương độ dài chuỗi, thường dẫn đến mức tiêu thụ bộ nhớ CUDA cao hơn đáng kể trong quá trình huấn luyện so với CNN truyền thống.
Ưu điểm và nhược điểm#
Ưu điểm chính của RTDETRv2 là thiết kế end-to-end nguyên bản. Bỏ qua NMS giúp model tránh các đột biến độ trễ liên quan đến dự đoán dày đặc, chồng lấn. Tuy nhiên, các khối Transformer đòi hỏi nhiều tài nguyên tính toán và GPU đáng kể cho cả huấn luyện lẫn triển khai, khiến model kém phù hợp hơn với thiết bị edge hạn chế tài nguyên hoặc phần cứng di động đời cũ.
YOLOX: Nâng cao CNN không anchor#
Được phát triển nhằm thu hẹp khoảng cách giữa nghiên cứu học thuật và ứng dụng công nghiệp, YOLOX giới thiệu head tách rời và thiết kế không anchor cho dòng model YOLO phổ biến.
- Tác giả: Zheng Ge, Songtao Liu, Feng Wang, Zeming Li và Jian Sun
- Tổ chức: Megvii
- Ngày: 18 tháng 7, 2021
- Liên kết: Bài báo arXiv, GitHub chính thức, Tài liệu
Kiến trúc và thiết kế#
YOLOX khác với các detector dựa trên anchor truyền thống ở chỗ dự đoán trực tiếp vị trí đối tượng mà không cần anchor box được xác định trước. Cách này đơn giản hóa thiết kế mạng và giảm số lượng tham số tinh chỉnh heuristic cần thiết để đạt hiệu năng tối ưu. Ngoài ra, YOLOX sử dụng head tách rời, phân chia tác vụ phân loại và hồi quy, giúp tăng tốc độ hội tụ trong quá trình huấn luyện.
Ưu điểm và nhược điểm#
Thiết kế không anchor giúp YOLOX thích ứng với nhiều tác vụ thị giác máy tính và dễ huấn luyện hơn trên các dataset tùy chỉnh. Các biến thể nhẹ nhất như YOLOX-Nano phù hợp với thiết bị di động và IoT công suất thấp. Tuy nhiên, YOLOX ra đời trước các detector không cần NMS và vẫn dựa vào bước hậu xử lý NMS, làm tăng độ phức tạp triển khai và độ trễ trong các cảnh có mật độ đối tượng cao.
So sánh hiệu năng và chỉ số#
Bảng dưới đây so sánh tốc độ, độ chính xác (mAP) và hiệu quả sử dụng tham số ở các kích thước model trên dataset COCO.
| Model | kích thước (pixel) | mAPval50-95 | Tốc độ CPU ONNX (ms) | Tốc độ T4 TensorRT10 (ms) | params (M) | FLOPs (B) |
|---|---|---|---|---|---|---|
| RTDETRv2-s | 640 | 48.1 | - | 5.03 | 20 | 60 |
| RTDETRv2-m | 640 | 51.9 | - | 7.51 | 36 | 100 |
| RTDETRv2-l | 640 | 53.4 | - | 9.76 | 42 | 136 |
| RTDETRv2-x | 640 | 54.3 | - | 15.03 | 76 | 259 |
| YOLOXnano | 416 | 25.8 | - | - | 0.91 | 1.08 |
| YOLOXtiny | 416 | 32.8 | - | - | 5.06 | 6.45 |
| YOLOXs | 640 | 40.5 | - | 2.56 | 9.0 | 26.8 |
| YOLOXm | 640 | 46.9 | - | 5.43 | 25.3 | 73.8 |
| YOLOXl | 640 | 49.7 | - | 9.04 | 54.2 | 155.6 |
| YOLOXx | 640 | 51.1 | - | 16.1 | 99.1 | 281.9 |
RTDETRv2 chính xác hơn ở mọi kích thước tương đương. RTDETRv2-x đạt 54.3 mAP so với 51.1 của YOLOXx, đồng thời nhanh hơn trên GPU T4 (15.03 ms so với 16.1 ms) và có ít tham số hơn (76M so với 99.1M). Ưu thế của YOLOX nằm ở nhóm model nhỏ: YOLOXs chạy trong 2.56 ms với 9.0M tham số (40.5 mAP), còn YOLOX-Nano và YOLOX-Tiny cung cấp các tùy chọn dưới 6M tham số mà RTDETRv2 không có.
Lợi thế Ultralytics: Giới thiệu YOLO26#
Nhiều dự án cần một model duy nhất kết hợp độ chính xác cao, inference nhanh và hệ sinh thái dễ tiếp cận. Ultralytics YOLO26, ra mắt vào tháng 1 năm 2026, được thiết kế để đáp ứng nhu cầu này.
Những đổi mới chính của YOLO26#
- Thiết kế đầu-cuối không cần NMS: Dựa trên phương pháp huấn luyện không cần NMS mà YOLOv10 đã giới thiệu cho các model YOLO, YOLO26 cung cấp head không cần NMS tùy chọn (
nms=False). Model mang lại khả năng suy luận đầu-cuối như RTDETRv2 mà không cần nhiều bộ nhớ như các Transformer. - Optimizer MuSGD: Lấy cảm hứng từ quá trình huấn luyện mô hình ngôn ngữ lớn (LLM), optimizer MuSGD lai (kết hợp SGD và Muon) giúp ổn định quá trình huấn luyện và tăng tốc hội tụ.
- Inference CPU nhanh hơn đến 43%: Loại bỏ module Distribution Focal Loss (DFL) giúp đơn giản hóa head cho điện toán edge và thiết bị công suất thấp, nhờ đó YOLO26n chạy trên CPU (ONNX) nhanh hơn đến 43% so với YOLO11n.
- ProgLoss + STAL: Progressive Loss và phương pháp gán nhãn nhận biết đối tượng nhỏ (STAL) cải thiện khả năng nhận diện đối tượng nhỏ, vốn là thách thức phổ biến trong ảnh chụp từ trên không và ứng dụng robotics.
Tính linh hoạt và hệ sinh thái#
Ngoài hiệu năng thuần, Ultralytics Platform hỗ trợ toàn bộ quy trình từ dữ liệu đến production. Khác với các repository học thuật tĩnh, model Ultralytics được duy trì tích cực và hỗ trợ nhiều tác vụ thông qua một API duy nhất. Dù bạn thực hiện phân đoạn instance, ước tính tư thế hay phát hiện bounding box định hướng (OBB), quy trình làm việc vẫn như nhau.
Model Ultralytics YOLO cũng cần ít bộ nhớ trong quá trình huấn luyện và inference, nhờ đó nhà nghiên cứu có thể chạy batch size lớn hơn trên phần cứng phổ thông so với các kiến trúc dựa trên Transformer vốn ngốn nhiều bộ nhớ.
Ví dụ mã huấn luyện#
Chỉ cần vài dòng code để huấn luyện model YOLO26; package Ultralytics xử lý việc tải dữ liệu và cấu hình siêu tham số mặc định.
from ultralytics import YOLO
# Initialize the YOLO26 Nano model
model = YOLO("yolo26n.pt")
# Train the model on the standard COCO8 dataset
results = model.train(data="coco8.yaml", epochs=100, imgsz=640, batch=16)
# Validate the model's performance
metrics = model.val()
print(f"Validation mAP: {metrics.box.map}")
# Export to ONNX or TensorRT for rapid deployment
model.export(format="engine", device=0)Ứng dụng thực tế và trường hợp sử dụng phù hợp#
Việc chọn kiến trúc phù hợp phụ thuộc vào các ràng buộc triển khai và phần cứng sẵn có.
Xử lý đám mây độ trung thực cao#
Nếu ứng dụng chạy trên GPU server cao cấp và ưu tiên độ chính xác tối đa—chẳng hạn như phân tích cảnh đám đông dày đặc hoặc xử lý ảnh y khoa độ phân giải cao—cơ chế attention của RTDETRv2 có thể phát huy hiệu quả.
Triển khai trên thiết bị biên đời cũ#
Với điện thoại di động đời cũ hoặc phần cứng nhúng bị giới hạn nghiêm ngặt, nơi FLOPs tối thiểu là yêu cầu bắt buộc, YOLOX-Nano nhẹ (0.91M tham số, 1.08B FLOPs) vẫn là lựa chọn dự phòng khả thi nhờ kiến trúc CNN đơn giản.
Tiêu chuẩn hiện đại: AIoT và robot#
Với hầu hết trường hợp sử dụng hiện đại, bao gồm hạ tầng thành phố thông minh, phân tích bán lẻ và điều hướng tự động, Ultralytics YOLO26 là lựa chọn được khuyến nghị. Khả năng inference CPU nhanh hơn YOLO11n đến 43% của YOLO26n phù hợp với điện toán edge, còn head không cần NMS tùy chọn mang lại độ trễ thấp và ổn định. Cùng với tài liệu Ultralytics và cộng đồng năng động, YOLO26 giúp các nhóm nhanh chóng chuyển từ gán nhãn dataset sang triển khai.
Sử dụng Ultralytics Platform để quản lý dataset, huấn luyện model trên cloud và triển khai ở quy mô lớn.
Các model Ultralytics khác đáng cân nhắc gồm YOLOv8, có khả năng tích hợp rộng rãi với cộng đồng, và YOLOv5, vẫn ổn định trong các pipeline cũ. Với dự án mới, YOLO26 là lựa chọn khởi đầu được khuyến nghị.
Bình luận6
Đặt câu hỏi, chia sẻ kết quả hoặc giúp đỡ người khác.
UltralyticsAssistantUltralytics
👋 Hello, thank you for opening a discussion and engaging with Ultralytics 🚀! For new users, we recommend visiting the Docs where you'll find detailed Python and CLI usage examples, as well as answers to many common questions.
If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us investigate further.
If your question is about custom training or model comparison ❓, please share as much detail as possible—such as dataset samples, training logs, or what specific performance metrics you're interested in. Don't forget to check out our Tips for Best Training Results for optimal guidance.
Join the Ultralytics community where you feel most comfortable:
- For real-time chat, head to Discord 🎧
- For in-depth discussions, visit Discourse
- Or explore threads on our Subreddit to share and learn with others
Upgrade
Please ensure you're using the latest
ultralyticspackage and all requirements in a Python>=3.8 environment with PyTorch>=1.8:pip install -U ultralyticsEnvironments
YOLO models can be run in any of the following up-to-date verified environments (with all dependencies, including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all Ultralytics CI tests are currently passing! CI tests verify correct operation of all YOLO Modes and Tasks across macOS, Windows, and Ubuntu every 24 hours and on every commit.
This is an automated response and an Ultralytics engineer will assist you soon 😊
Glenn JocherUltralytics(đã chỉnh sửa)This page offers a valuable comparison between RTDETRv2 and YOLOX, highlighting their different strengths. If you have specific questions about these models, feel free to ask here. RTDETRv2 excels in accuracy (reaching 54.3% mAP) but demands more computational resources, while YOLOX stands out for efficiency and speed, making it ideal for edge devices. For those seeking alternatives with a balance of performance and usability, you might also consider Ultralytics YOLO26, which offers excellent performance across various computer vision tasks. What specific aspect of these models are you most interested in learning more about?
UltralyticsAssistantUltralytics
👋 Hello, thank you for starting this comparison discussion about RTDETRv2 and YOLOX! 🚀 For detailed guidance, we recommend checking out our Docs, which contain in-depth information, benchmarks, and usage examples that may help answer many of your questions.
If this is a 🐛 Bug Report, please provide a minimum reproducible example so we can assist you efficiently.
For model training or evaluation ❓ Questions, please share as many details as possible, such as dataset samples, training logs, or specific requirements, and review our Tips for Best Training Results.
Join the Ultralytics community in your preferred space! For real-time chat, visit our Discord 🎧. For topic-based discussions, check out Discourse, or connect with others on our Subreddit.
Upgrade
Make sure your
ultralyticspackage and all requirements are up to date in a Python>=3.8 environment with PyTorch>=1.8:pip install -U ultralyticsEnvironments
YOLO models can be run in these verified environments:
- Notebooks with free GPU:
- Google Cloud Deep Learning VM: GCP Quickstart Guide
- Amazon Deep Learning AMI: AWS Quickstart Guide
- Docker Image: Docker Quickstart Guide
Status
A green badge means all Ultralytics CI tests are passing. CI covers all YOLO Modes and Tasks across macOS, Windows, and Ubuntu.
This is an automated response 🤖. An Ultralytics engineer will review your discussion and provide further assistance soon!
Glenn JocherUltralytics(đã chỉnh sửa)Welcome to the RTDETRv2 vs YOLOX comparison discussion! This page highlights two powerful object detection approaches with different strengths: RTDETRv2 leverages transformer architecture for higher accuracy in complex scenes (54.3% mAP for RTDETRv2-x), while YOLOX offers exceptional efficiency with faster inference speed (2.56ms for YOLOX-s on T4 TensorRT).
Your use case should guide your choice - RTDETRv2 excels when maximum accuracy is critical and GPU resources are available, while YOLOX is ideal for edge devices and real-time applications with limited resources.
If you're looking for models within a comprehensive ecosystem, you might also consider Ultralytics YOLO26 which balances performance with ease of use.
Feel free to post any questions about these models or their implementation in your specific applications. The Ultralytics team is here to help!
- Notebooks with free GPU:
UltralyticsAssistantUltralytics
👋 Hello, thank you for starting this discussion and sharing your interest in comparing object detection models like RTDETRv2 and YOLOX 🚀! For a detailed overview, the Ultralytics Docs offer a wealth of information, including the comparison page you linked, which highlights model strengths, performance, and use cases.
If you have specific questions or encounter any issues related to these models, please provide as much detail as possible.
- If this is a 🐛 Bug Report, please include a minimum reproducible example to help us assist you.
- For custom training ❓ questions, adding dataset samples and training logs can be very helpful. Make sure to review our Training Tips for best results.
Connect with the Ultralytics community in your preferred way! For real-time help, join our Discord 🎧. In-depth posts and discussions are found on Discourse, and our Subreddit is great for sharing experiences and solutions.
Upgrade
To ensure the best experience and access to the latest features and fixes, please upgrade the
ultralyticspackage and all requirements in a Python>=3.8 environment with PyTorch>=1.8:pip install -U ultralyticsEnvironments
YOLO models can be run in any of these verified environments with all dependencies preinstalled:
- Notebooks with free GPU:
- Google Cloud Deep Learning VM (GCP Quickstart Guide)
- Amazon Deep Learning AMI (AWS Quickstart Guide)
- Docker Image (Docker Quickstart Guide)
Status
A green badge means all Ultralytics CI tests are passing, ensuring YOLO Modes and Tasks work across macOS, Windows, and Ubuntu.
This is an automated response 🤖—an Ultralytics engineer will review your discussion and assist you soon!
Glenn JocherUltralytics(đã chỉnh sửa)Welcome to the discussion about RTDETRv2 and YOLOX object detection models! Both offer different strengths - RTDETRv2 provides higher accuracy through its transformer architecture, while YOLOX excels in speed and efficiency on resource-constrained devices.
If you have specific questions about implementing either model, performance tuning, or need help choosing between them for your particular use case, please share your questions here. Our team monitors these discussions to provide technical guidance and support.
For hands-on users interested in similar models with Ultralytics integration, YOLO26 offers an excellent balance of speed and accuracy with full support in our ecosystem.