Bắt đầu

Meituan YOLOv6

Tổng quan#

Meituan YOLOv6, phát hành năm 2022, là model phát hiện đối tượng mang lại sự cân bằng tốt giữa tốc độ và độ chính xác, khiến model trở thành lựa chọn phổ biến cho các ứng dụng thời gian thực. Model này giới thiệu một số cải tiến đáng chú ý về kiến trúc và quy trình huấn luyện, bao gồm triển khai module Nối hai chiều (BiC), chiến lược huấn luyện có hỗ trợ anchor (AAT), cùng thiết kế backbone và neck được cải tiến để đạt độ chính xác cao trên dataset COCO.

Model phát hiện đối tượng thời gian thực YOLOv6 của Meituan Sơ đồ kiến trúc model YOLOv6 Tổng quan về YOLOv6. Sơ đồ kiến trúc model thể hiện các thành phần mạng và chiến lược huấn luyện được thiết kế lại, mang lại những cải thiện hiệu năng đáng kể. (a) Neck của YOLOv6 (hiển thị N và S). Lưu ý: với M/L, RepBlocks được thay bằng CSPStackRep. (b) Cấu trúc của module BiC. (c) Khối SimCSPSPPF. (nguồn).

Tính năng chính#

  • Module ghép nối hai chiều (BiC): YOLOv6 giới thiệu module BiC trong neck của bộ phát hiện, giúp tăng cường tín hiệu định vị và cải thiện hiệu năng mà gần như không làm giảm tốc độ.
  • Chiến lược huấn luyện có hỗ trợ anchor (AAT): AAT kết hợp ưu điểm của cả hai phương pháp dựa trên anchor và không anchor mà không làm giảm hiệu quả suy luận.
  • Thiết kế backbone và neck nâng cao: Bằng cách mở rộng YOLOv6 để bổ sung một stage vào backbone và neck, model này đạt hiệu năng cao trên dataset COCO với đầu vào độ phân giải cao tại thời điểm ra mắt.
  • Chiến lược tự chưng cất: Một chiến lược tự chưng cất mới được triển khai để cải thiện hiệu năng của các model YOLOv6 nhỏ hơn, tăng cường nhánh hồi quy phụ trong quá trình huấn luyện và loại bỏ nhánh này khi suy luận để tránh giảm đáng kể tốc độ.

Chỉ số hiệu năng#

YOLOv6 cung cấp nhiều model pretrained với các kích thước khác nhau:

  • YOLOv6-N: 37,5% AP trên COCO val2017 ở tốc độ 1187 FPS với GPU NVIDIA T4.
  • YOLOv6-S: 45,0% AP ở tốc độ 484 FPS.
  • YOLOv6-M: 50,0% AP ở tốc độ 226 FPS.
  • YOLOv6-L: 52,8% AP ở tốc độ 116 FPS.
  • YOLOv6-L6: Độ chính xác hiện đại nhất trong thời gian thực.

YOLOv6 cũng cung cấp các model lượng tử hóa với nhiều độ chính xác số khác nhau và các model được tối ưu hóa cho nền tảng di động.

Ví dụ sử dụng#

Ví dụ này cung cấp các ví dụ đơn giản về huấn luyện và suy luận YOLOv6.

Ví dụ

Có thể truyền các tệp YOLOv6 *.yaml vào class YOLO() để dựng model tương ứng trong Python:

from ultralytics import YOLO

# Dựng model YOLOv6n từ đầu
model = YOLO("yolov6n.yaml")

# Hiển thị thông tin model (không bắt buộc)
model.info()

# Huấn luyện model trên dataset mẫu COCO8 trong 100 epoch
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)

# Chạy suy luận bằng model YOLOv6n trên ảnh 'bus.jpg'
results = model("path/to/bus.jpg")

Các tác vụ và chế độ được hỗ trợ#

Dòng YOLOv6 cung cấp nhiều model, mỗi model được tối ưu hóa cho phát hiện đối tượng, đáp ứng nhiều mức ngân sách tính toán và yêu cầu về độ chính xác khác nhau.

ModelTên tệpTác vụHuấn luyệnValidationSuy luậnExport
YOLOv6-Nyolov6n.yamlPhát hiện đối tượng✅✅✅✅
YOLOv6-Syolov6s.yamlPhát hiện đối tượng✅✅✅✅
YOLOv6-Myolov6m.yamlPhát hiện đối tượng✅✅✅✅
YOLOv6-Lyolov6l.yamlPhát hiện đối tượng✅✅✅✅
YOLOv6-Xyolov6x.yamlPhát hiện đối tượng✅✅✅✅

Bảng này tóm tắt các biến thể model YOLOv6 và khả năng hỗ trợ các chế độ Huấn luyện, Xác thực, Suy luận và Xuất. Ultralytics chỉ cung cấp các tệp YAML của model YOLOv6, vì vậy model được huấn luyện từ đầu.

Trích dẫn và lời cảm ơn#

Chúng tôi xin ghi nhận những đóng góp quan trọng của các tác giả trong lĩnh vực phát hiện đối tượng theo thời gian thực:

Trích dẫn
@misc{li2023yolov6,
      title={YOLOv6 v3.0: A Full-Scale Reloading},
      author={Chuyi Li and Lulu Li and Yifei Geng and Hongliang Jiang and Meng Cheng and Bo Zhang and Zaidan Ke and Xiaoming Xu and Xiangxiang Chu},
      year={2023},
      eprint={2301.05586},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

Có thể tìm thấy bài báo YOLOv6 gốc trên arXiv. Các tác giả đã công khai công trình của mình và mã nguồn có thể truy cập trên GitHub. Chúng tôi trân trọng nỗ lực của họ trong việc thúc đẩy lĩnh vực này và giúp cộng đồng rộng lớn hơn tiếp cận công trình.

Câu hỏi thường gặp#

  • Meituan YOLOv6, ra mắt năm 2022, là bộ phát hiện đối tượng cân bằng giữa tốc độ và độ chính xác, được thiết kế cho các ứng dụng thời gian thực. Model này có những cải tiến kiến trúc đáng chú ý như module Bi-directional Concatenation (BiC) và chiến lược Anchor-Aided Training (AAT). Những đổi mới này cải thiện đáng kể hiệu năng mà chỉ làm giảm tốc độ ở mức tối thiểu, khiến YOLOv6 trở thành lựa chọn cạnh tranh cho các tác vụ phát hiện đối tượng.

  • Module Bi-directional Concatenation (BiC) trong YOLOv6 tăng cường tín hiệu định vị ở neck của bộ phát hiện, cải thiện hiệu năng mà hầu như không ảnh hưởng đến tốc độ. Module này kết hợp hiệu quả các feature map khác nhau, tăng khả năng phát hiện đối tượng chính xác của model. Để biết thêm chi tiết về các tính năng của YOLOv6, hãy tham khảo mục Tính năng chính.

  • Bạn có thể huấn luyện model YOLOv6 bằng Ultralytics với các lệnh Python hoặc CLI đơn giản. Ví dụ:

    Ví dụ
    from ultralytics import YOLO
    
    # Dựng model YOLOv6n từ đầu
    model = YOLO("yolov6n.yaml")
    
    # Huấn luyện model trên dataset mẫu COCO8 trong 100 epoch
    results = model.train(data="coco8.yaml", epochs=100, imgsz=640)

    Để biết thêm thông tin, hãy truy cập trang Huấn luyện.

  • YOLOv6 có nhiều phiên bản, mỗi phiên bản được tối ưu hóa cho các yêu cầu hiệu năng khác nhau:

    • YOLOv6-N: 37,5% AP ở tốc độ 1187 FPS
    • YOLOv6-S: 45,0% AP ở tốc độ 484 FPS
    • YOLOv6-M: 50,0% AP ở tốc độ 226 FPS
    • YOLOv6-L: 52,8% AP ở tốc độ 116 FPS
    • YOLOv6-L6: Độ chính xác hiện đại nhất trong các tình huống thời gian thực

    Các model này được đánh giá trên dataset COCO bằng GPU NVIDIA T4. Để biết thêm về các chỉ số hiệu năng, hãy xem mục Chỉ số hiệu năng.

  • Anchor-Aided Training (AAT) trong YOLOv6 kết hợp các yếu tố của phương pháp dựa trên anchor và không dùng anchor, tăng cường khả năng phát hiện của model mà không ảnh hưởng đến hiệu quả suy luận. Chiến lược này tận dụng anchor trong quá trình huấn luyện để cải thiện dự đoán bounding box, giúp YOLOv6 hoạt động hiệu quả trong nhiều tác vụ phát hiện đối tượng.

  • YOLOv6 hỗ trợ các chế độ Huấn luyện, Validation, Suy luận và Export.

Bình luận14

Đặt câu hỏi, chia sẻ kết quả hoặc giúp đỡ người khác.

  1. AkaashSamsonGitHub

    Hey, So I have actually trained my YOLOv6 model with the original repo, now I have a .pt file. using this file is there any way of getting my model in ultralytics format. mainly I want to run the ultralytics validation on my model as the original repo eval.py doesn't provide sufficient metrics.

    1. Glenn JocherUltralytics

      Direct conversion of Meituan YOLOv6 .pt checkpoints to Ultralytics format isn’t supported; to use Ultralytics metrics, either train/fine-tune the matching yolov6*.yaml in Ultralytics and run validation, or export your Meituan model’s detections to COCO JSON and compute P/R via the COCO API; the metrics Ultralytics reports are outlined in the Val mode docs at Ultralytics validation.

  2. tino926GitHub(đã chỉnh sửa)

    I want to replicate your training accuracy of the YOLOv6-N model. Is this the correct command: yolo train model=yolov6n.yaml data=coco.yaml epochs=400 optimizer=SGD cos_lr=True lr0=0.02? According to YOLOv6's repo https://github.com/meituan/YOLOv6/blob/main/docs/Train_coco_data.md, they have to use anchor-aid and distilling techniques to achieve this accuracy. But I can't find the corresponding parameters in ultralytics'.

    1. Glenn JocherUltralytics

      @tino926 to achieve the training accuracy of the YOLOv6-N model as described in the YOLOv6 repository, you would indeed use the anchor-aided training (AAT) and self-distillation strategies, which are not explicitly parameterized in the Ultralytics YOLO interface. Ensure you are using the latest version and check the YOLOv6 documentation for any updates on incorporating these strategies. For precise replication, consider following the original YOLOv6 GitHub instructions alongside Ultralytics for any additional settings or configurations.

    2. tino926GitHub

      @glenn-jocher, thanks for your response.

      I apologize if I misunderstood your explanation, as I am not a native English speaker. Could you please clarify if the phrase "which are not explicitly parameterized in the Ultralytics YOLO interface" means that AAT and self-distillation cannot currently be implemented solely through the Ultralytics YOLO interface? Therefore I should manually add anchor branches and implement distillation with additional code?

    3. Glenn JocherUltralytics

      Thank you for your question. Yes, that's correct. The current Ultralytics YOLO interface does not explicitly support anchor-aided training (AAT) and self-distillation, so you would need to implement these strategies manually by modifying the code to include anchor branches and self-distillation techniques. If you need further guidance on implementing these, referring to the original YOLOv6 repository might be helpful.

  3. kadirnarGitHub

    Does ultralytics library support yolov6 model?

    ModuleNotFoundError: No module named 'yolov6'

    1. Paula DerrengerUltralytics(đã chỉnh sửa)

      @kadirnar hi there!

      Yes, the Ultralytics library does support YOLOv6 models. It seems like you might be encountering a ModuleNotFoundError because the YOLOv6 model isn't being recognized. Let's ensure you're using the latest versions of torch and ultralytics. Please update your packages and try again:

      pip install --upgrade torch ultralytics

      Here's a quick example to get you started with YOLOv6 using the Ultralytics library:

      Python
      from ultralytics import YOLO
      
      # Load a YOLOv6n model
      model = YOLO("yolov6n.yaml")
      
      # Train the model on the COCO8 example dataset for 100 epochs
      results = model.train(data="coco8.yaml", epochs=100, imgsz=640)
      
      # Run inference with the trained model on an image
      results = model("path/to/bus.jpg")
      CLI
      # Train YOLOv6n model
      yolo train model=yolov6n.yaml data=coco8.yaml epochs=100 imgsz=640
      
      # Run inference with your trained weights
      yolo predict model=path/to/best.pt source=path/to/bus.jpg

      If you continue to face issues, please provide a minimum reproducible example so we can better assist you. You can refer to our guide on creating a minimum reproducible example here: Minimum Reproducible Example.

      Feel free to reach out if you have any more questions! 😊

  4. akhilesh99sharmaGitHub

    There are AP and AR values for results but not precision and recall. I need to compare precision and recall values for different YOLO versions (v5,v6,v7 etc.) on my custom dataset. How to get precision and recall values for YOLOv6 evaluation?

    1. Paula DerrengerUltralytics(đã chỉnh sửa)

      Hey there! 👋

      You don't need to compute precision and recall by hand: validation already reports them. After model.val(), the results object holds them directly:

      from ultralytics import YOLO
      
      # Load your trained model
      model = YOLO("path/to/your/custom-yolov6-model.pt")
      
      # Run validation
      results = model.val(data="path/to/your/dataset.yaml")
      
      print(f"Precision: {results.box.mp}, Recall: {results.box.mr}")  # mean over all classes
      print(results.box.p, results.box.r)  # per-class precision and recall

      Hope this helps, and happy comparing across YOLO versions! 🚀

    2. Paula DerrengerUltralytics(đã chỉnh sửa)

      Hey there! 😊

      Precision and recall are reported by Ultralytics validation, so you don't need to count TP/FP/FN yourself. After results = model.val(data="path/to/dataset.yaml"), use results.box.mp (mean precision), results.box.mr (mean recall), and results.box.p / results.box.r for per-class values.

      If you need them computed from raw counts, precision = TP / (TP + FP) and recall = TP / (TP + FN), where the counts come from matching predictions to ground-truth boxes at an IoU threshold.

      Hope this helps! Let me know if there's anything else I can do for you. Happy modeling! 🚀

    3. akhilesh99sharmaGitHub

      Hello, I tried doing it but was not able to do so. I get the predictions json file in the val folder but don't know how to compare it with the labels to get TP, FP etc. Can you please help me with that? I need to compare results of YOLOv6 with v8, v9 but I am not getting precision and recall values in v6 , I get average precision and average recall

    4. Paula DerrengerUltralytics(đã chỉnh sửa)

      @akhilesh99sharma hey there! 🌞

      You can get precision and recall directly from validation without processing the predictions JSON yourself. After results = model.val(data="path/to/dataset.yaml"), use results.box.mp (mean precision), results.box.mr (mean recall), and results.box.p / results.box.r for per-class values.

      If you still need TP, FP and FN counts from the saved predictions JSON, you will have to match predicted boxes to ground-truth boxes per image using an IoU threshold. The confusion matrix saved in the run folder (confusion_matrix.png, or model.val(plots=True)) also shows these counts per class.

      For comparing across YOLO versions, run each model with consistent settings on your custom dataset and read the same metrics from each.

      I hope this simplifies the process for you! 🚀 Let me know if you need further assistance.