YOLOv8—运行mode=track报错 ERROR: subprocess-exited-with-error与 ERROR: Failed building wheel for lap解决

YOLOv8是Ultralytics公司开发的一个尖端的、最先进的(SOTA)模型,它建立在以前YOLO版本的成功基础上,并引入了新的功能和改进,进一步提升了性能和灵活性。YOLOv8被设计为快速、准确和易于使用,使其成为广泛的物体检测、图像分割和图像分类任务的绝佳选择。

在我们自创数据集训练后,可以通过训练生成的“best.pt”权重进行视频追踪。但是在首次运行track模式时会报些许错误。如 ERROR: subprocess-exited-with-error与 ERROR: Failed building wheel for lap。本贴即为记录解决上述问题。

ps:篇幅过长,解法直接点击下述内容。

我按照解决导包思路依次解决,分为以下步骤:

 一、pip install -r requirements.txt 失败

 二、直接pip install lap==0.4 失败

 三、conda install -c conda-forge lap 成功

 四、YOLOv8运行


 

3eb3fe09bb47414188701b9fb9d89df7.png

(yolov8) E:\z\code\ultralytics-main\ultralytics-main>yolo cfg = ultralytics/yolo/cfg/default.yaml
Overriding D:\Anaconda3\envs\yolov8\Lib\site-packages\ultralytics\yolo\cfg\default.yaml with ultralytics/yolo/cfg/default.yaml
requirements: YOLOv8 requirement "lap>=0.4" not found, attempting AutoUpdate...
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      Partial import of lap during the build process.
      Generating cython files
      running bdist_wheel
      running build
      running config_cc
      unifing config_cc, config, build_clib, build_ext, build commands --compiler options
      running config_fc
      unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
      running build_src
      build_src
      building extension "lap._lapjv" sources
      building data_files sources
      build_src: building npy-pkg config files
      D:\Anaconda3\envs\yolov8\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-b
ased tools.
        setuptools.SetuptoolsDeprecationWarning,
      running build_py
      creating build
      creating build\lib.win-amd64-3.7
      creating build\lib.win-amd64-3.7\lap
      copying lap\lapmod.py -> build\lib.win-amd64-3.7\lap
      copying lap\__init__.py -> build\lib.win-amd64-3.7\lap
      running build_ext
      No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
      customize MSVCCompiler
      customize MSVCCompiler using build_ext
      CCompilerOpt.cc_test_flags[1013] : testing flags (/O2)
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      CCompilerOpt.cache_flush[809] : write cache to path -> C:\Users\Admin\AppData\Local\Temp\pip-install-f83ct1c9\lap_4334ef16f3b74b75a9eec341ab7bd4c8\build\temp.win-amd64-3.7\Releas
e\ccompiler_opt_cache_ext.py
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lap
  error: subprocess-exited-with-error

  × Running setup.py install for lap did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      Partial import of lap during the build process.
      Generating cython files
      running install
      D:\Anaconda3\envs\yolov8\lib\site-packages\setuptools\command\install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-b
ased tools.
        setuptools.SetuptoolsDeprecationWarning,
      running build
      running config_cc
      unifing config_cc, config, build_clib, build_ext, build commands --compiler options
      running config_fc
      unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
      running build_src
      build_src
      building extension "lap._lapjv" sources
      building data_files sources
      build_src: building npy-pkg config files
      running build_py
      creating build
      creating build\lib.win-amd64-3.7
      creating build\lib.win-amd64-3.7\lap
      copying lap\lapmod.py -> build\lib.win-amd64-3.7\lap
      copying lap\__init__.py -> build\lib.win-amd64-3.7\lap
      running build_ext
      No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
      customize MSVCCompiler
      customize MSVCCompiler using build_ext
      CCompilerOpt.cc_test_flags[1013] : testing flags (/O2)
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      CCompilerOpt.cache_flush[809] : write cache to path -> C:\Users\Admin\AppData\Local\Temp\pip-install-f83ct1c9\lap_4334ef16f3b74b75a9eec341ab7bd4c8\build\temp.win-amd64-3.7\Releas
e\ccompiler_opt_cache_ext.py
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lap

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
requirements:  Command 'pip install "lap>=0.4"  ' returned non-zero exit status 1.
Traceback (most recent call last):
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\tracker\utils\matching.py", line 10, in <module>
    import lap  # for linear_assignment
ModuleNotFoundError: No module named 'lap'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Anaconda3\envs\yolov8\Scripts\yolo-script.py", line 33, in <module>
    sys.exit(load_entry_point('ultralytics==8.0.61', 'console_scripts', 'yolo')())
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\yolo\cfg\__init__.py", line 374, in entrypoint
    getattr(model, mode)(**overrides)  # default args from model
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\yolo\engine\model.py", line 242, in track
    from ultralytics.tracker import register_tracker
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\tracker\__init__.py", line 3, in <module>
    from .track import register_tracker
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\tracker\track.py", line 8, in <module>
    from .trackers import BOTSORT, BYTETracker
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\tracker\trackers\__init__.py", line 3, in <module>
    from .bot_sort import BOTSORT
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\tracker\trackers\bot_sort.py", line 7, in <module>
    from ..utils import matching
  File "D:\Anaconda3\envs\yolov8\lib\site-packages\ultralytics\tracker\utils\matching.py", line 16, in <module>
    import lap
ModuleNotFoundError: No module named 'lap'
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-Break to quit
 

一、pip install -r requirements.txt 失败

 一开始,我以为是没有lap这个包,于是直接在requirements.txt文件中添加“lap>=0.4”,然后在使用“pip install -r requirements.txt”发现还是报错。然后我把添加的“lap>=0.4”删掉。

1ba1eda771f24725af57bf93c495ac63.png

 二、直接pip install lap==0.4 失败

于是又想着直接pip安装(我还使用了阿里云镜像),结果还是没用。

pip install lap==0.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

cef3f5cad9e746d19bc7858531d4f46d.png

 三、conda install -c conda-forge lap 成功

后面使用如下命令便安装成功。

conda install -c conda-forge lap

 707c25c5dfdf4143aaf2d9109c684aca.png

四、YOLOv8运行

接着运行我的yolov8,在终端直接输入

yolo cfg = ultralytics/yolo/cfg/default.yaml 

99c11df0ad314060a5d93e9dd4ff43d8.png 五、检查YOLOv8模型效果

当运行完毕后,会生成一个存放视频追踪结果的文件夹,打开视频。由于在我所用视频为眼科白内障手术,为了不影响观感,截取部分画面。从中可以看到识别视频中的手术器材和人眼组织的准确率都达到了0.9以上。从中可以看出YOLOv8图像识别的功能着实强大!

89b4b1321472428ba965aa57312331d6.png

 

以上便是此次YOLOv8运行track模式解决报错全过程,希望对正在使用YOLOv8的你有用!

 

  • 13
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值