请问如何使用yolo的分类模型,有可以参考的demo吗?

  • lihualihua_1 wrote: 2024-10-24 22:15 我使用python export.py --rknpu --weight .\yolov5s-cls.pt导出onnx模型时发生了错误

    Code: Select all

    Fusing layers... 
    Model summary: 117 layers, 5447688 parameters, 0 gradients, 11.4 GFLOPs
    export detect model for RKNPU
    Traceback (most recent call last):
      File "D:\Documents\code\luckfox_yolov5\train\yolov5\export.py", line 724, in <module>
        main(opt)
      File "D:\Documents\code\luckfox_yolov5\train\yolov5\export.py", line 718, in main
        run(**vars(opt))
      File "C:\Users\hutao\anaconda3\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
        return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
      File "D:\Documents\code\luckfox_yolov5\train\yolov5\export.py", line 617, in run
        model.model[-1]._register_detect_seperate(True)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\hutao\anaconda3\Lib\site-packages\torch\nn\modules\module.py", line 1729, in __getattr__
        raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
    AttributeError: 'Classify' object has no attribute '_register_detect_seperate'
    您好,你可以参考这个示例:https://wiki.luckfox.com/zh/Luckfox-Pic ... 错你应该使用这个命令 python export.py --rknpu --weight yolov5s.pt。你尝试导出yolov5s-cls.pt分类模型,但是脚本希望导出的是yolov5s.pt检测模型。
  • Alenwowo wrote: 2024-10-25 1:57
    lihualihua_1 wrote: 2024-10-24 22:15 我使用python export.py --rknpu --weight .\yolov5s-cls.pt导出onnx模型时发生了错误

    Code: Select all

    Fusing layers... 
    Model summary: 117 layers, 5447688 parameters, 0 gradients, 11.4 GFLOPs
    export detect model for RKNPU
    Traceback (most recent call last):
      File "D:\Documents\code\luckfox_yolov5\train\yolov5\export.py", line 724, in <module>
        main(opt)
      File "D:\Documents\code\luckfox_yolov5\train\yolov5\export.py", line 718, in main
        run(**vars(opt))
      File "C:\Users\hutao\anaconda3\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
        return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
      File "D:\Documents\code\luckfox_yolov5\train\yolov5\export.py", line 617, in run
        model.model[-1]._register_detect_seperate(True)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\hutao\anaconda3\Lib\site-packages\torch\nn\modules\module.py", line 1729, in __getattr__
        raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
    AttributeError: 'Classify' object has no attribute '_register_detect_seperate'
    您好,你可以参考这个示例:https://wiki.luckfox.com/zh/Luckfox-Pic ... 错你应该使用这个命令 python export.py --rknpu --weight yolov5s.pt。你尝试导出yolov5s-cls.pt分类模型,但是脚本希望导出的是yolov5s.pt检测模型。
    不支持yolo的cls分类模型吗?
  • 您好,根据您提供的报错信息来看应该是使用的库版本不匹配导致'Classify' 模块找不到 '_register_detect_seperate',建议使用conda 或其他虚拟环境工具搭建开发环境,以避免版本不匹配的问题