###配置MMFashion环境
最近需要做一个着装检测的项目,于是想试一下MMFashion的效果,MMFashion的官方链接在这https://github.com/open-mmlab/mmfashion
安装环境:
Pytorch 1.6.4
python 3.6.4
mmcv
按照readme的步骤:
git clone --recursive https://github.com/open-mmlab/mmfashion.git
cd mmfashion
python setup.py install
在第一步git clone时,除了mmfashion的git,还有个远端的文件,等待它下载完成。
在最后一步,setup.py执行时报了网络连接的错误,其实是requirements.txt中需要的依赖文件缺失,对应下载即可:
matplotlib
mmcv>=0.5.1
numpy
scikit-image
scikit-learn
对于mmcv这个包,它是用于计算机视觉研究的基础python库,支持mmlab中的许多研究项目,https://github.com/open-mmlab/mmcv,按照mmcv的read me,有两种安装方式:
(a)直接pip安装
pip install mmcv
(b)离线安装
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install -e . #安装轻量版本
MMCV_WITH_OPS=1 pip install -e . #安装完整版full version
两种方法都试了,会在安装过程中出现这样的报错:
(Pytorch) wnj@wnj:~/venvs$ pip --default-timeout=1000 install mmcv -i https://pypi.mirrors.ustc.edu.cn/simple/
Looking in indexes: https://pypi.mirrors.ustc.edu.cn/simple/
Collecting mmcv
Using cached https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/7e/0f/71adf51180d7afabe790482f1c8f1129ab6b6fcc7bc7c010691ab67c936f/mmcv-1.1.1.tar.gz (239 kB)
ERROR: Command errored out with exit status 1:
command: /home/wnj/venvs/Pytorch/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ju15ld3t/mmcv/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ju15ld3t/mmcv/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-ju15ld3t/mmcv/pip-egg-info
cwd: /tmp/pip-install-ju15ld3t/mmcv/
Complete output (80 lines):
ERROR: Exception:
Traceback (most recent call last):
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 425, in _error_catcher
yield
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 507, in read
data = self._fp.read(amt) if not fp_closed else b""
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/usr/local/lib/python3.6/http/client.py", line 449, in read
n = self.readinto(b)
File "/usr/local/lib/python3.6/http/client.py", line 493, in readinto
n = self.fp.readinto(b)
File "/usr/local/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/usr/local/lib/python3.6/ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "/usr/local/lib/python3.6/ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "/usr/local/lib/python3.6/ssl.py", line 631, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/commands/wheel.py", line 161, in run
resolver.resolve(requirement_set)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
hashes=hashes,
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 287, in unpack_url
hashes=hashes,
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 159, in unpack_http_url
link, downloader, temp_dir.path, hashes
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 303, in _download_http_url
for chunk in download.chunks:
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_internal/network/utils.py", line 39, in response_chunks
decode_content=False,
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 564, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 529, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/local/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 430, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
Traceback (most recent call last):
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
subprocess.check_call(cmd)
File "/usr/local/lib/python3.6/subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/wnj/venvs/Pytorch/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp9bbyslld', '--quiet', 'Cython']' returned non-zero exit status 2.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-ju15ld3t/mmcv/setup.py", line 8, in <module>
dist.Distribution().fetch_build_eggs(['Cython', 'numpy>=1.11.1'])
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/setuptools/dist.py", line 721, in fetch_build_eggs
replace_conflicting=True,
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pkg_resources/__init__.py", line 783, in resolve
replace_conflicting=replace_conflicting
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1066, in best_match
return self.obtain(req, installer)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1078, in obtain
return installer(requirement)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/setuptools/dist.py", line 777, in fetch_build_egg
return fetch_build_egg(self, req)
File "/home/wnj/venvs/Pytorch/lib/python3.6/site-packages/setuptools/installer.py", line 130, in fetch_build_egg
raise DistutilsError(str(e))
distutils.errors.DistutilsError: Command '['/home/wnj/venvs/Pytorch/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp9bbyslld', '--quiet', 'Cython']' returned non-zero exit status 2.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
其实是mmcv的依赖项未建立,主要有:
pytest-runner
pytest
addict
numpy
pyyaml
yapf
opencv-python
配置好后,再执行python setup.py install 就可以顺利执行了。
版权声明:本文为weixin_43350700原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。