赞
踩
yolov5的官方文件
链接:https://pan.baidu.com/s/1WNoTDvBGDrgTfUiHDSB6Gg?pwd=8MXz
提取码:8MXz
在终端里面运行detect.py文件,报下面的错误
分析上面的错误,发现是在utils/general.py
文件里的39行处报错了。因为找不到check_requirements
。解决办法如下。
解决方法:
1、找到你的yolov5文件夹,找到utils/general.py
2、打开general.py文件。删除utils/general.py文件下39行代码,即下面的这行代码
from ultralytics.yolo.utils.checks import check_requirements
3、将下面的代码拷贝到utils/general.py中345行代码之后
@TryExcept()
def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), install=True, cmds=''):
# Check installed dependencies meet YOLOv5 requirements (pass *.txt file or list of packages or single package str)
prefix = colorstr('red', 'bold', 'requirements:')
check_python() # check python version
if isinstance(requirements, Path): # requirements.txt file
file = requirements.resolve()
assert file.exists(), f'{prefix} {file} not found, check failed.'
with file.open() as f:
requirements = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements(f) if x.name not in exclude]
elif isinstance(requirements, str):
requirements = [requirements]
s = ''
n = 0
for r in requirements:
try:
pkg.require(r)
except (pkg.VersionConflict, pkg.DistributionNotFound): # exception if requirements not met
s += f'"{r}" '
n += 1
if s and install and AUTOINSTALL: # check environment variable
LOGGER.info(f"{prefix} YOLOv5 requirement{'s' * (n > 1)} {s}not found, attempting AutoUpdate...")
try:
# assert check_online(), "AutoUpdate skipped (offline)"
LOGGER.info(check_output(f'pip install {s} {cmds}', shell=True).decode())
source = file if 'file' in locals() else requirements
s = f"{prefix} {n} package{'s' * (n > 1)} updated per {source}\n" \
f"{prefix} ⚠️ {colorstr('bold', 'Restart runtime or rerun command for updates to take effect')}\n"
LOGGER.info(s)
except Exception as e:
LOGGER.warning(f'{prefix} ❌ {e}')
4、之后成功运行,即可成功,成功结果如下。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。