【问题标题】:Yolov5 TFLite model detects too slow after uint8 quantizationYolov5 TFLite模型检测到uint8量化后太慢
【发布时间】:2022-08-08 16:47:31
【问题描述】:

我的 Yolov5 模型旨在检测类:[\'book\'、\'calculator\'、\'mobilephone\'、\'pencilcase\'、\'stickynotes\']。所以我用我的自定义数据集训练了 Yolov5m 权重。将其导出为 TFLite fp16 格式时,我的模型在每帧几乎 0.3 秒内检测到它们。然而,当量化时,推理每帧需要近一分钟。

我的问题是:

  1. 自然吗?还是有一些错误?
  2. 如果有一些错误,我该如何修复它们?
    #Quantization Code: Through export.py
    
    !python export.py --img 640 --conf 0.25 --weights /content/drive/MyDrive/new_yolov5/runs/train/20220523_1945003/weights/best.pt --include tflite
    
    #Inference: Through detect.py
    
    !python detect.py --data /content/drive/MyDrive/test5_mk_od/data/dataset.yaml --weights /content/drive/MyDrive/new_yolov5/runs/train/20220523_1945003/weights/best-int8.tflite --img 640 --conf 0.4 --source /content/drive/MyDrive/test_detect/20220512_165148.mp4
    

    [结果]

    /content/drive/MyDrive/test_yolov5/yolov5
    detect: weights=[\'/content/drive/MyDrive/new_yolov5/runs/train/20220523_1945003/weights/best-int8.tflite\'], source=/content/drive/MyDrive/test_detect/20220512_165148.mp4, data=/content/drive/MyDrive/test5_mk_od/data/dataset.yaml, imgsz=[640, 640], conf_thres=0.4, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False
    YOLOv5 ???? v6.1-251-gc23a441 Python-3.7.13 torch-1.11.0+cu113 CUDA:0 (Tesla V100-SXM2-16GB, 16160MiB)
    
    Loading /content/drive/MyDrive/new_yolov5/runs/train/20220523_1945003/weights/best-int8.tflite for TensorFlow Lite inference...
    video 1/1 (1/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (67.038s)
    video 1/1 (2/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Mobile phone, Done. (66.943s)
    video 1/1 (3/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Mobile phone, Done. (66.823s)
    video 1/1 (4/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Mobile phone, Done. (66.778s)
    video 1/1 (5/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Mobile phone, Done. (67.330s)
    video 1/1 (6/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.728s)
    video 1/1 (7/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.651s)
    video 1/1 (8/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.916s)
    video 1/1 (9/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.856s)
    video 1/1 (10/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.744s)
    video 1/1 (11/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.890s)
    video 1/1 (12/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (66.197s)
    video 1/1 (13/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 2 Calculators, 1 Mobile phone, Done. (64.246s)
    video 1/1 (14/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (64.453s)
    video 1/1 (15/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (63.961s)
    video 1/1 (16/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (63.685s)
    video 1/1 (17/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (64.103s)
    video 1/1 (18/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, 1 Mobile phone, Done. (64.889s)
    video 1/1 (19/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 2 Calculators, 1 Mobile phone, Done. (64.448s)
    video 1/1 (20/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 2 Calculators, Done. (65.044s)
    video 1/1 (21/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 2 Calculators, Done. (64.319s)
    video 1/1 (22/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 1 Calculator, Done. (64.063s)
    video 1/1 (23/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 Done. (64.529s)
    video 1/1 (24/265) /content/drive/.shortcut-targets-by-id/10NptF8SByCfLxhPaEiZzFKNYzF-G2Ul5/test_detect/20220512_165148.mp4: 640x640 Done. (64.778s)
    

    标签: quantization yolov5


    【解决方案1】:

    我面临同样的问题。你得到解决方案了吗?请建议我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-10
      • 2022-12-30
      • 2021-07-23
      • 1970-01-01
      • 2023-01-17
      • 2021-03-05
      • 2020-02-09
      • 1970-01-01
      相关资源
      最近更新 更多