FastestDet

dog-qiuqiuBSD-3-Clause更新放缓

超轻量无锚框目标检测算法,权重仅 250K 参数,比 yolo-fastest 快 10%,后处理更简单,适合边缘设备部署。

:zap: A newly designed ultra lightweight anchor free target detection algorithm, weight only 250K parameters, reduces the time consumption by 10% compared with yolo-fastest, and the post-processing is simpler

v1.0发布于 2022-07-02 01:54 UTC863star150fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
pip install -r requirements.txt
python3 test.py --yaml configs/coco.yaml --weight weights/weight_AP05:0.253207_280-epoch.pth --img data/3.jpg
硬件要求按 README 说明

README 未说明显存要求;基准测试在 RK3568 ARM CPU、骁龙 835、i7-8700 上基于 NCNN 运行,并给出 RK3568 NPU 的 rknn 结果,未列出支持的 GPU 厂商或型号

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

超轻量无锚框目标检测算法,仅 250K 参数,比 Yolo-fastest 更快且后处理更简单

超轻量无锚框目标检测算法,权重仅 250K 参数,比 yolo-fastest 快 10%,后处理更简单,适合边缘设备部署。

核心能力

  • 采用 Anchor-Free 与单尺度检测头设计
  • 跨网格多候选目标与动态正负样本分配
  • 后处理比 Yolo-fastest 更简单,性能提升约 10%
  • 支持导出 ONNX 与 TorchScript 部署
  • 提供 NCNN 与 onnx-runtime 部署示例

容易踩的坑

安装 PyTorch 时需自行选择对应的 CUDA 版本;测试与评估需使用仓库提供的 .pth 权重文件;NCNN 示例需预先编译 ncnn 和 opencv 并修改 build.sh 中的路径

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

1 个版本v1.0
  1. v1.0first commit最新正式版2022-07-02 · 2022-07-02 01:54 UTC

    first commit

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    2022.7.14:Optimize loss, adopt IOU aware based on smooth L1, and the AP is significantly increased by 0.7

    :zap:FastestDet:zap:

    DOI image image image

    • Faster! Stronger! Simpler!
    • It has better performance and simpler feature map post-processing than Yolo-fastest
    • The performance is 10% higher than Yolo-fastest
    • The coco evaluation index increased by 1.2% compared with the map0.5 of Yolo-fastestv2
    • 算法介绍:https://zhuanlan.zhihu.com/p/536500269 交流qq群:1062122604

    Evaluating indicator/Benchmark

    NetworkmAPval 0.5mAPval 0.5:0.95ResolutionRun Time(4xCore)Run Time(1xCore)Params(M)
    yolov5s56.8%37.4%640X640395.31ms1139.16ms7.2M
    yolov6n-30.8%416X416109.24ms445.44ms4.3M
    yolox-nano-25.8%416X41676.31ms191.16ms0.91M
    nanodet_m-20.6%320X32049.24ms160.35ms0.95M
    yolo-fastestv1.124.40%-320X32026.60ms75.74ms0.35M
    yolo-fastestv224.10%-352X35223.8ms68.9ms0.25M
    FastestDet25.3%13.0%352X35223.51ms70.62ms0.24M
    • Test platform Radxa Rock3A RK3568 ARM Cortex-A55 CPU,Based on NCNN
    • CPU lock frequency 2.0GHz

    Improvement

    • Anchor-Free
    • Single scale detector head
    • Cross grid multiple candidate targets
    • Dynamic positive and negative sample allocation

    Multi-platform benchmark

    EquipmentComputing backendSystemFrameworkRun time(Single core)Run time(Multi core)
    Radxa rock3aRK3568(arm-cpu)Linux(aarch64)ncnn70.62ms23.51ms
    Radxa rock3aRK3568(NPU)Linux(aarch64)rknn28ms-
    QualcommSnapdragon 835(arm-cpu)Android(aarch64)ncnn32.34ms16.24ms
    Inteli7-8700(X86-cpu)Linux(amd64)ncnn4.51ms4.33ms

    How to use

    Dependent installation

    • PiP(Note pytorch CUDA version selection)
      pip install -r requirements.txt
      

    Test

    • Picture test
      python3 test.py --yaml configs/coco.yaml --weight weights/weight_AP05:0.253207_280-epoch.pth --img data/3.jpg
      

    How to train

    Building data sets(The dataset is constructed in the same way as darknet yolo)

    • The format of the data set is the same as that of Darknet Yolo, Each image corresponds to a .txt label file. The label format is also based on Darknet Yolo's data set label format: "category cx cy wh", where category is the category subscript, cx, cy are the coordinates of the center point of the normalized label box, and w, h are the normalized label box The width and height, .txt label file content example as follows:

      11 0.344192634561 0.611 0.416430594901 0.262
      14 0.509915014164 0.51 0.974504249292 0.972
      
    • The image and its corresponding label file have the same name and are stored in the same directory. The data file structure is as follows:

      .
      ├── train
      │   ├── 000001.jpg
      │   ├── 000001.txt
      │   ├── 000002.jpg
      │   ├── 000002.txt
      │   ├── 000003.jpg
      │   └── 000003.txt
      └── val
          ├── 000043.jpg
          ├── 000043.txt
          ├── 000057.jpg
          ├── 000057.txt
          ├── 000070.jpg
          └── 000070.txt
      
    • Generate a dataset path .txt file, the example content is as follows:

      train.txt

      /home/qiuqiu/Desktop/dataset/train/000001.jpg
      /home/qiuqiu/Desktop/dataset/train/000002.jpg
      /home/qiuqiu/Desktop/dataset/train/000003.jpg
      

      val.txt

      /home/qiuqiu/Desktop/dataset/val/000070.jpg
      /home/qiuqiu/Desktop/dataset/val/000043.jpg
      /home/qiuqiu/Desktop/dataset/val/000057.jpg
      
    • Generate the .names category label file, the sample content is as follows:

      category.names

      person
      bicycle
      car
      motorbike
      ...
      
      
    • The directory structure of the finally constructed training data set is as follows:

      .
      ├── category.names        # .names category label file
      ├── train                 # train dataset
      │   ├── 000001.jpg
      │   ├── 000001.txt
      │   ├── 000002.jpg
      │   ├── 000002.txt
      │   ├── 000003.jpg
      │   └── 000003.txt
      ├── train.txt              # train dataset path .txt file
      ├── val                    # val dataset
      │   ├── 000043.jpg
      │   ├── 000043.txt
      │   ├── 000057.jpg
      │   ├── 000057.txt
      │   ├── 000070.jpg
      │   └── 000070.txt
      └── val.txt                # val dataset path .txt file
      
      

    Build the training .yaml configuration file

    • Reference./configs/coco.yaml
      DATASET:
        TRAIN: "/home/qiuqiu/Desktop/coco2017/train2017.txt"  # Train dataset path .txt file
        VAL: "/home/qiuqiu/Desktop/coco2017/val2017.txt"      # Val dataset path .txt file 
        NAMES: "dataset/coco128/coco.names"                   # .names category label file
      MODEL:
        NC: 80                                                # Number of detection categories
        INPUT_WIDTH: 352                                      # The width of the model input image
        INPUT_HEIGHT: 352                                     # The height of the model input image
      TRAIN:
        LR: 0.001                                             # Train learn rate
        THRESH: 0.25                                          # ????
        WARMUP: true                                          # Trun on warm up
        BATCH_SIZE: 64                                        # Batch size
        END_EPOCH: 350                                        # Train epichs
        MILESTIONES:                                          # Declining learning rate steps
          - 150
          - 250
          - 300
      

    Train

    • Perform training tasks
      python3 train.py --yaml configs/coco.yaml
      

    Evaluation

    • Calculate map evaluation
      python3 eval.py --yaml configs/coco.yaml --weight weights/weight_AP05:0.253207_280-epoch.pth
      
    • COCO2017 evaluation
      creating index...
      index created!
      creating index...
      index created!
      Running per image evaluation...
      Evaluate annotation type *bbox*
      DONE (t=30.85s).
      Accumulating evaluation results...
      DONE (t=4.97s).
      Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.130
      Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.253
      Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.119
      Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.021
      Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.129
      Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.237
      Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.142
      Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.208
      Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.214
      Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.043
      Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.236
      Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.372
      
      

    Deploy

    Export onnx

    • You can export .onnx by adding the --onnx option when executing test.py
      python3 test.py --yaml configs/coco.yaml --weight weights/weight_AP05:0.253207_280-epoch.pth --img data/3.jpg --onnx
      

    Export torchscript

    • You can export .pt by adding the --torchscript option when executing test.py
      python3 test.py --yaml configs/coco.yaml --weight weights/weight_AP05:0.253207_280-epoch.pth --img data/3.jpg --torchscript
      

    NCNN

    • Need to compile ncnn and opencv in advance and modify the path in build.sh
      cd example/ncnn/
      sh build.sh
      ./FastestDet
      

    onnx-runtime

    • You can learn about the pre and post-processing methods of FastestDet in this Sample
      cd example/onnx-runtime
      pip install onnx-runtime
      python3 runtime.py
      

    Citation

    • If you find this project useful in your research, please consider cite:
      @misc{=FastestDet,
            title={FastestDet: Ultra lightweight anchor-free real-time object detection algorithm.},
            author={xuehao.ma},
            howpublished = {\url{https://github.com/dog-qiuqiu/FastestDet}},
            year={2022}
      }
      

    Reference