yolov5(cpu)配置


yolov5配置(cpu)

#打开anaconda命令窗
conda create -n yolov5 python=3.8

activate yolov5 

git clone https://github.com/ultralytics/yolov5.git

#cd 进入到yolov5目录中
pip install -U -r requirements.txt

yolov5测试

在官网下载yolov5代码以及模型(.pt文件)https://github.com/ultralytics/yolov5
打开yolov5文件夹输入

python detect.py --source 0 --weight E:\chengxu\yolov5\weights\yolov5s.pt

bug及解决方法

问题描述

 Building wheel for pycocotools (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'E:\anaconda\anaconda\envs\yolov5\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\WYD\\AppData\\Local\\Temp\\pip-install-j7554uaz\\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\\setup.py'"'"'; __file__='"'"'C:\\Users\\WYD\\AppData\\Local\\Temp\\pip-install-j7554uaz\\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\WYD\AppData\Local\Temp\pip-wheel-zb3vvgqh'
       cwd: C:\Users\WYD\AppData\Local\Temp\pip-install-j7554uaz\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\
  Complete output (16 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.8
  creating build\lib.win-amd64-3.8\pycocotools
  copying pycocotools\coco.py -> build\lib.win-amd64-3.8\pycocotools
  copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.8\pycocotools
  copying pycocotools\mask.py -> build\lib.win-amd64-3.8\pycocotools
  copying pycocotools\__init__.py -> build\lib.win-amd64-3.8\pycocotools
  running build_ext
  cythoning pycocotools/_mask.pyx to pycocotools\_mask.c
  c:\users\wyd\appdata\local\temp\pip-install-j7554uaz\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\.eggs\cython-0.29.22-py3.8-win-amd64.egg\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\WYD\AppData\Local\Temp\pip-install-j7554uaz\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\pycocotools\_mask.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  building 'pycocotools._mask' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
  ----------------------------------------
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
Failed to build pycocotools
Installing collected packages: urllib3, pyasn1, idna, chardet, six, rsa, requests, pyasn1-modules, oauthlib, cachetools, typing-extensions, requests-oauthlib, pytz, python-dateutil, pyparsing, Pillow, numpy, kiwisolver, google-auth, cycler, werkzeug, torch, tensorboard-plugin-wit, scipy, protobuf, pandas, matplotlib, markdown, grpcio, google-auth-oauthlib, Cython, absl-py, tqdm, torchvision, thop, tensorboard, seaborn, PyYAML, pycocotools, opencv-python
    Running setup.py install for pycocotools ... error
    ERROR: Command errored out with exit status 1:
     command: 'E:\anaconda\anaconda\envs\yolov5\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\WYD\\AppData\\Local\\Temp\\pip-install-j7554uaz\\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\\setup.py'"'"'; __file__='"'"'C:\\Users\\WYD\\AppData\\Local\\Temp\\pip-install-j7554uaz\\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\WYD\AppData\Local\Temp\pip-record-hnl0f5un\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\anaconda\anaconda\envs\yolov5\Include\pycocotools'
         cwd: C:\Users\WYD\AppData\Local\Temp\pip-install-j7554uaz\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\
    Complete output (14 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    creating build\lib.win-amd64-3.8\pycocotools
    copying pycocotools\coco.py -> build\lib.win-amd64-3.8\pycocotools
    copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.8\pycocotools
    copying pycocotools\mask.py -> build\lib.win-amd64-3.8\pycocotools
    copying pycocotools\__init__.py -> build\lib.win-amd64-3.8\pycocotools
    running build_ext
    skipping 'pycocotools\_mask.c' Cython extension (up-to-date)
    building 'pycocotools._mask' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'E:\anaconda\anaconda\envs\yolov5\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\WYD\\AppData\\Local\\Temp\\pip-install-j7554uaz\\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\\setup.py'"'"'; __file__='"'"'C:\\Users\\WYD\\AppData\\Local\\Temp\\pip-install-j7554uaz\\pycocotools_95037ce57904498d8c947bc8cb6b7ab2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\WYD\AppData\Local\Temp\pip-record-hnl0f5un\install-record.txt' --single-version-externally-managed --compile --install-headers 'E:\anaconda\anaconda\envs\yolov5\Include\pycocotools' Check the logs for full command output.

解决方法

打开网址:https://github.com/philferriere/cocoapi
点击hear下载visual c++2015
在这里插入图片描述
然后从gittee上面下载(这样快):https://gitee.com/jiangjiajun/philferriere-cocoapi?_from=gitee_search
最后进入到PythonAPI文件夹内输入:python setup.py build_ext --inplace

(yolov5) E:\chengxu\philferriere-cocoapi\PythonAPI>python setup.py build_ext --inplace

学习时间

2021.3.11


猜你喜欢

转载自blog.csdn.net/qq_44181970/article/details/114681567