赞
踩
为毕设做准备,今天学习并安装部署了PaddleDetection。
参考文章:
如何用PaddleDetection做一个完整的目标检测项目 - 知乎 (zhihu.com)https://zhuanlan.zhihu.com/p/340717675
文章中指出要利用利用anaconda创建一个名字叫做paddle-detection的Paddle环境,我好像没有做到,而是直接安装的。
安装链接在参考文章中给出,这里复制过来:
开始使用https://www.paddlepaddle.org.cn/install/quick需要注意的是,我的计算机没有 NVIDIA® GPU而是集显,需要安装CPU版本的PaddleDetection
最后验证安装
安装链接中给出了如何卸载,这里不做操作,回到参考文章,进行下一步安装COCO-API。
- 1 pip install Cython
- 2 pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
其中在执行第二个pip命令时,不断出现问题:
- C:\Users\86134>pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
- Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
- Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
- Cloning https://github.com/philferriere/cocoapi.git to c:\users\86134\appdata\local\temp\pip-req-build-agx11kr8
- Running command git clone --filter=blob:none --quiet https://github.com/philferriere/cocoapi.git 'C:\Users\86134\AppData\Local\Temp\pip-req-build-agx11kr8'
- Resolved https://github.com/philferriere/cocoapi.git to commit 2929bd2ef6b451054755dfd7ceb09278f935f7ad
- Preparing metadata (setup.py) ... done
- Building wheels for collected packages: pycocotools
- Building wheel for pycocotools (setup.py) ... error
- error: subprocess-exited-with-error
-
- × python setup.py bdist_wheel did not run successfully.
- │ exit code: 1
- ╰─> [1 lines of output]
- 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/
- [end of output]
-
- note: This error originates from a subprocess, and is likely not a problem with pip.
- ERROR: Failed building wheel for pycocotools
- Running setup.py clean for pycocotools
- error: subprocess-exited-with-error
-
- × python setup.py clean did not run successfully.
- │ exit code: 1
- ╰─> [12 lines of output]
- Traceback (most recent call last):
- File "<string>", line 2, in <module>
- File "<pip-setuptools-caller>", line 34, in <module>
- File "C:\Users\86134\AppData\Local\Temp\pip-req-build-agx11kr8\PythonAPI\setup.py", line 25, in <module>
- cythonize(ext_modules)
- File "D:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1010, in cythonize
- module_list, module_metadata = create_extension_list(
- File "D:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 845, in create_extension_list
- for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
- File "D:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 117, in nonempty
- raise ValueError(error_msg)
- ValueError: 'pycocotools/_mask.pyx' doesn't match any files
- [end of output]
- note: This error originates from a subprocess, and is likely not a problem with pip.
- ERROR: Failed cleaning build dir for pycocotools
- Failed to build pycocotools
- ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects

咨询chart-GPT,给出参考意见:
这里将他给出的Microsoft C++ Build Tools安装链接:
Microsoft C++ Build Tools - Visual Studiohttps://visualstudio.microsoft.com/visual-cpp-build-tools/同时上图可看到
后续甚至出现了git环境变量错误的问题,使用everything搜索,发现可能是安装Microsoft C++ Build Tools时,利用Visual Studio Installer同时安装了Visual Studio Community 2022导致,现在看来似乎安装的这两个(一个生成工具,一个community)都没啥用
利用everything找到之前安装的git的安装目录C:\Program Files\Git\bin,重新添加到系统变量即可
Git配置环境变量和结果检测http://t.csdnimg.cn/nIctD
这里在利用参考文章中第二种方式下载时,不断出现网络连接错误导致下载失败
故直接采用第一种方式下载zip
放在了文件夹:C:\Users\86134\PaddleDetection下
不同于参考文章中的版本,似乎内容更多了
另外,他开始时使用了activate paddle激活环境,但是我在开头第一步时没有建立
那么我应该是在base环境中,不论如何,继续安装,并且 pip install -r requirements.txt
不断报出一些多个不兼容的依赖项问题,使用命令:
pip install --upgrade mysql-connector-python paddlepaddle tensorflow typeguard typing-extensions
这将尝试升级"mysql-connector-python"、"paddlepaddle"、"tensorflow"、"typeguard"和"typing-extensions"到最新版本,以解决依赖项冲突。
- 1 set PYTHONPATH=`pwd`:$PYTHONPATH
- 2 python ppdet/modeling/tests/test_architectures.py
在执行第二命令时同样出现了运行错误,由于在第一次配置时,直接在解压的文件夹下配置的,可以看到我的路径中含有中文
故我转移了文件夹到C:\Users\86134\PaddleDetection\PaddleDetection-release-2.7,
利用everything找到在C盘的test_architectures.py按照参考文章中的方式添加代码
最后也确实运行出了文章中的结果,给我输出了一个“OK”,表示配置成功。
------------------------------------------------------------------------------------------------------------------------------
set PYTHONPATH=
pwd:$PYTHONPATH
是一个设置环境变量 PYTHONPATH
的命令。
在 Python 中,PYTHONPATH
是一个环境变量,用于指定额外的模块搜索路径。当你导入自定义的模块或库时,Python 解释器会在 PYTHONPATH
中指定的路径下搜索相应的模块。
上述命令的含义是将当前目录(使用 pwd
命令获取)添加到 PYTHONPATH
环境变量中,并且保留原有的路径配置。
这个命令通常在运行 Python 脚本之前执行,以确保 Python 解释器可以找到所需的模块或库。通过将当前目录添加到 PYTHONPATH
中,Python 解释器将能够在该目录下搜索并导入你自己编写的模块。
请注意,这个命令在不同的操作系统和命令行环境下可能会有所不同。以上命令是针对类 Unix 系统(如 Linux 或 macOS)的命令行环境使用的。如果你使用的是 Windows 系统,可以尝试使用以下命令:
set PYTHONPATH=%cd%;%PYTHONPATH%
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。