admin 管理员组文章数量: 887021
版本:
(base) C:\WINDOWS\system32>conda --version
conda 4.5.12
C:\Users\admin
λ python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
1.官网下载Anaconda安装包
我在官网下载anaconda安装包速度漫道令人发指,然后我就放弃了,去清华的镜像网站上下载的,
https://mirrors.tuna.tsinghua.edu/anaconda/archive/
但是安装完之后都只有一个anaconda prompt.
而且按照https://zhuanlan.zhihu/p/32925500 这个上面提供的方法试验也没用,报错conda不是内部或外部命令什么的错误,重装了几次后都是这样。后来在csdn上看到一个博主的解决方法,具体链接忘记了。。。sorry
按照那个博主的解决方法,找一个成功安装了anaconda的电脑,然后把安装成功的文件夹打包拷到自己的电脑上解压,在下面这个目录下进入命令行,
执行命令:
python .\Lib\_nsis.py mkmenus
然后 开始菜单的地方会出现安装成功的五个快捷方式,但是点击Anaconda Navigator 报错:无法进入图形化界面。
解决方法:
输入conda list:
(base) C:\WINDOWS\system32>conda list
# packages in environment at C:\Users\admin\Anaconda3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py37_0 defaults
alabaster 0.7.12 py37_0 defaults
anaconda 2018.12 py37_0 defaults
anaconda-client 1.7.2 py37_0 defaults
anaconda-navigator 1.9.6 py37_0 defaults
anaconda-project 0.8.2 py37_0 defaults
asn1crypto 0.24.0 py37_0 defaults
astroid 2.1.0 py37_0 defaults
astropy 3.1 py37he774522_0 defaults
atomicwrites 1.2.1 py37_0 defaults
attrs 18.2.0 py37h28b3542_0 defaults
babel 2.6.0 py37_0 defaults
backcall 0.1.0 py37_0 defaults
backports 1.0 py37_1 defaults
backports.os 0.1.1 py37_0 defaults
backports.shutil_get_terminal_size 1.0.0 py37_2 defaults
beautifulsoup4 4.6.3 py37_0 defaults
bitarray 0.8.3 py37hfa6e2cd_0 defaults
bkcharts 0.2 py37_0 defaults
blas 1.0 mkl defaults
blaze 0.11.3 py37_0 defaults
bleach 3.0.2 py37_0 defaults
blosc 1.14.4 he51fdeb_0 defaults
bokeh 1.0.2 py37_0 defaults
boto 2.49.0 py37_0 defaults
bottleneck 1.2.1 py37h452e1ab_1 defaults
bzip2 1.0.6 hfa6e2cd_5 defaults
ca-certificates 2018.03.07 0 defaults
certifi 2018.11.29 py37_0 defaults
cffi 1.11.5 py37h74b6da3_1 defaults
chardet 3.0.4 py37_1 defaults
click 7.0 py37_0 defaults
cloudpickle 0.6.1 py37_0 defaults
clyent 1.2.2 py37_1 defaults
colorama 0.4.1 py37_0 defaults
comtypes 1.1.7 py37_0 defaults
conda 4.5.12 py37_0 defaults
conda-build 3.17.6 py37_0 defaults
conda-env 2.6.0 1 defaults
conda-verify 3.1.1 py37_0 defaults
console_shortcut 0.1.1 3 defaults
contextlib2 0.5.5 py37_0 defaults
cryptography 2.4.2 py37h7a1dbc1_0 defaults
curl 7.63.0 h2a8f88b_1000 defaults
cycler 0.10.0 py37_0 defaults
cython 0.29.2 py37ha925a31_0 defaults
cytoolz 0.9.0.1 py37hfa6e2cd_1 defaults
dask 1.0.0 py37_0 defaults
dask-core 1.0.0 py37_0 defaults
datashape 0.5.4 py37_1 defaults
decorator 4.3.0 py37_0 defaults
defusedxml 0.5.0 py37_1 defaults
distributed 1.25.1 py37_0 defaults
docutils 0.14 py37_0 defaults
entrypoints 0.2.3 py37_2 defaults
et_xmlfile 1.0.1 py37_0 defaults
fastcache 1.0.2 py37hfa6e2cd_2 defaults
filelock 3.0.10 py37_0 defaults
flask 1.0.2 py37_1 defaults
flask-cors 3.0.7 py37_0 defaults
freetype 2.9.1 ha9979f8_1 defaults
future 0.17.1 py37_0 defaults
get_terminal_size 1.0.0 h38e98db_0 defaults
gevent 1.3.7 py37he774522_1 defaults
glob2 0.6 py37_1 defaults
greenlet 0.4.15 py37hfa6e2cd_0 defaults
h5py 2.8.0 py37h3bdd7fb_2 defaults
hdf5 1.10.2 hac2f561_1 defaults
heapdict 1.0.0 py37_2 defaults
html5lib 1.0.1 py37_0 defaults
icc_rt 2019.0.0 h0cc432a_1 defaults
icu 58.2 ha66f8fd_1 defaults
idna 2.8 py37_0 defaults
imageio 2.4.1 py37_0 defaults
imagesize 1.1.0 py37_0 defaults
importlib_metadata 0.6 py37_0 defaults
intel-openmp 2019.1 144 defaults
ipykernel 5.1.0 py37h39e3cac_0 defaults
ipython 7.2.0 py37h39e3cac_0 defaults
ipython_genutils 0.2.0 py37_0 defaults
ipywidgets 7.4.2 py37_0 defaults
isort 4.3.4 py37_0 defaults
itsdangerous 1.1.0 py37_0 defaults
jdcal 1.4 py37_0 defaults
jedi 0.13.2 py37_0 defaults
jinja2 2.10 py37_0 defaults
jpeg 9b hb83a4c4_2 defaults
jsonschema 2.6.0 py37_0 defaults
jupyter 1.0.0 py37_7 defaults
jupyter_client 5.2.4 py37_0 defaults
jupyter_console 6.0.0 py37_0 defaults
jupyter_core 4.4.0 py37_0 defaults
jupyterlab 0.35.3 py37_0 defaults
jupyterlab_server 0.2.0 py37_0 defaults
keyring 17.0.0 py37_0 defaults
kiwisolver 1.0.1 py37h6538335_0 defaults
krb5 1.16.1 hc04afaa_7 defaults
lazy-object-proxy 1.3.1 py37hfa6e2cd_2 defaults
libarchive 3.3.3 h0643e63_5 defaults
libcurl 7.63.0 h2a8f88b_1000 defaults
libiconv 1.15 h1df5818_7 defaults
libpng 1.6.35 h2a8f88b_0 defaults
libsodium 1.0.16 h9d3ae62_0 defaults
libssh2 1.8.0 h7a1dbc1_4 defaults
libtiff 4.0.9 h36446d0_2 defaults
libxml2 2.9.8 hadb2253_1 defaults
libxslt 1.1.32 hf6f1972_0 defaults
llvmlite 0.26.0 py37ha925a31_0 defaults
locket 0.2.0 py37_1 defaults
lxml 4.2.5 py37hef2cd61_0 defaults
lz4-c 1.8.1.2 h2fa13f4_0 defaults
lzo 2.10 h6df0209_2 defaults
m2w64-gcc-libgfortran 5.3.0 6 defaults
m2w64-gcc-libs 5.3.0 7 defaults
m2w64-gcc-libs-core 5.3.0 7 defaults
m2w64-gmp 6.1.0 2 defaults
m2w64-libwinpthread-git 5.0.0.4634.697f757 2 defaults
markupsafe 1.1.0 py37he774522_0 defaults
matplotlib 3.0.2 py37hc8f65d3_0 defaults
mccabe 0.6.1 py37_1 defaults
menuinst 1.4.14 py37hfa6e2cd_0 defaults
mistune 0.8.4 py37he774522_0 defaults
mkl 2019.1 144 defaults
mkl-service 1.1.2 py37hb782905_5 defaults
mkl_fft 1.0.6 py37h6288b17_0 defaults
mkl_random 1.0.2 py37h343c172_0 defaults
more-itertools 4.3.0 py37_0 defaults
mpmath 1.1.0 py37_0 defaults
msgpack-python 0.5.6 py37he980bc4_1 defaults
msys2-conda-epoch 20160418 1 defaults
multipledispatch 0.6.0 py37_0 defaults
navigator-updater 0.2.1 py37_0 defaults
nbconvert 5.4.0 py37_1 defaults
nbformat 4.4.0 py37_0 defaults
networkx 2.2 py37_1 defaults
nltk 3.4 py37_1 defaults
nose 1.3.7 py37_2 defaults
notebook 5.7.4 py37_0 defaults
numba 0.41.0 py37hf9181ef_0 defaults
numexpr 2.6.8 py37hdce8814_0 defaults
numpy 1.15.4 py37h19fb1c0_0 defaults
numpy-base 1.15.4 py37hc3f5095_0 defaults
numpydoc 0.8.0 py37_0 defaults
odo 0.5.1 py37_0 defaults
olefile 0.46 py37_0 defaults
openpyxl 2.5.12 py37_0 defaults
openssl 1.1.1a he774522_0 defaults
packaging 18.0 py37_0 defaults
pandas 0.23.4 py37h830ac7b_0 defaults
pandoc 1.19.2.1 hb2460c7_1 defaults
pandocfilters 1.4.2 py37_1 defaults
parso 0.3.1 py37_0 defaults
partd 0.3.9 py37_0 defaults
path.py 11.5.0 py37_0 defaults
pathlib2 2.3.3 py37_0 defaults
patsy 0.5.1 py37_0 defaults
pep8 1.7.1 py37_0 defaults
pickleshare 0.7.5 py37_0 defaults
pillow 5.3.0 py37hdc69c19_0 defaults
pip 18.1 py37_0 defaults
pkginfo 1.4.2 py37_1 defaults
pluggy 0.8.0 py37_0 defaults
ply 3.11 py37_0 defaults
prometheus_client 0.5.0 py37_0 defaults
prompt_toolkit 2.0.7 py37_0 defaults
psutil 5.4.8 py37he774522_0 defaults
py 1.7.0 py37_0 defaults
pycodestyle 2.4.0 py37_0 defaults
pycosat 0.6.3 py37hfa6e2cd_0 defaults
pycparser 2.19 py37_0 defaults
pycrypto 2.6.1 py37hfa6e2cd_9 defaults
pycurl 7.43.0.2 py37h7a1dbc1_0 defaults
pyflakes 2.0.0 py37_0 defaults
pygments 2.3.1 py37_0 defaults
pylint 2.2.2 py37_0 defaults
pyodbc 4.0.25 py37ha925a31_0 defaults
pyopenssl 18.0.0 py37_0 defaults
pyparsing 2.3.0 py37_0 defaults
pyqt 5.9.2 py37h6538335_2 defaults
pysocks 1.6.8 py37_0 defaults
pytables 3.4.4 py37he6f6034_0 defaults
pytest 4.0.2 py37_0 defaults
pytest-arraydiff 0.3 py37h39e3cac_0 defaults
pytest-astropy 0.5.0 py37_0 defaults
pytest-doctestplus 0.2.0 py37_0 defaults
pytest-openfiles 0.3.1 py37_0 defaults
pytest-remotedata 0.3.1 py37_0 defaults
python 3.7.1 h8c8aaf0_6 defaults
python-dateutil 2.7.5 py37_0 defaults
python-libarchive-c 2.8 py37_6 defaults
pytz 2018.7 py37_0 defaults
pywavelets 1.0.1 py37h8c2d366_0 defaults
pywin32 223 py37hfa6e2cd_1 defaults
pywinpty 0.5.5 py37_1000 defaults
pyyaml 3.13 py37hfa6e2cd_0 defaults
pyzmq 17.1.2 py37hfa6e2cd_0 defaults
qt 5.9.7 vc14h73c81de_0 [vc14] defaults
qtawesome 0.5.3 py37_0 defaults
qtconsole 4.4.3 py37_0 defaults
qtpy 1.5.2 py37_0 defaults
requests 2.21.0 py37_0 defaults
rope 0.11.0 py37_0 defaults
ruamel_yaml 0.15.46 py37hfa6e2cd_0 defaults
scikit-image 0.14.1 py37ha925a31_0 defaults
scikit-learn 0.20.1 py37h343c172_0 defaults
scipy 1.1.0 py37h29ff71c_2 defaults
seaborn 0.9.0 py37_0 defaults
send2trash 1.5.0 py37_0 defaults
setuptools 40.6.3 py37_0 defaults
simplegeneric 0.8.1 py37_2 defaults
singledispatch 3.4.0.3 py37_0 defaults
sip 4.19.8 py37h6538335_0 defaults
six 1.12.0 py37_0 defaults
snappy 1.1.7 h777316e_3 defaults
snowballstemmer 1.2.1 py37_0 defaults
sortedcollections 1.0.1 py37_0 defaults
sortedcontainers 2.1.0 py37_0 defaults
sphinx 1.8.2 py37_0 defaults
sphinxcontrib 1.0 py37_1 defaults
sphinxcontrib-websupport 1.1.0 py37_1 defaults
spyder 3.3.2 py37_0 defaults
spyder-kernels 0.3.0 py37_0 defaults
sqlalchemy 1.2.15 py37he774522_0 defaults
sqlite 3.26.0 he774522_0 defaults
statsmodels 0.9.0 py37h452e1ab_0 defaults
sympy 1.3 py37_0 defaults
tblib 1.3.2 py37_0 defaults
terminado 0.8.1 py37_1 defaults
testpath 0.4.2 py37_0 defaults
tk 8.6.8 hfa6e2cd_0 defaults
toolz 0.9.0 py37_0 defaults
tornado 5.1.1 py37hfa6e2cd_0 defaults
tqdm 4.28.1 py37h28b3542_0 defaults
traitlets 4.3.2 py37_0 defaults
unicodecsv 0.14.1 py37_0 defaults
urllib3 1.24.1 py37_0 defaults
vc 14.1 h0510ff6_4 defaults
vs2015_runtime 14.15.26706 h3a45250_0 defaults
wcwidth 0.1.7 py37_0 defaults
webencodings 0.5.1 py37_1 defaults
werkzeug 0.14.1 py37_0 defaults
wheel 0.32.3 py37_0 defaults
widgetsnbextension 3.4.2 py37_0 defaults
win_inet_pton 1.0.1 py37_1 defaults
win_unicode_console 0.5 py37_0 defaults
wincertstore 0.2 py37_0 defaults
winpty 0.4.3 4 defaults
wrapt 1.10.11 py37hfa6e2cd_2 defaults
xlrd 1.2.0 py37_0 defaults
xlsxwriter 1.1.2 py37_0 defaults
xlwings 0.15.1 py37_0 defaults
xlwt 1.3.0 py37_0 defaults
xz 5.2.4 h2fa13f4_4 defaults
yaml 0.1.7 hc54c509_2 defaults
zeromq 4.2.5 he025d50_1 defaults
zict 0.1.3 py37_0 defaults
zlib 1.2.11 h62dcd97_3 defaults
zstd 1.3.7 h508b16e_0 defaults
(base) C:\WINDOWS\system32>
Anaconda Navigator也可以启动了,不过在图形化界面新建环境不成功。报错:Multiple Errors Encountered.
然后就退出了,尝试换成命令行创建环境,报错:
(base) C:\WINDOWS\system32>conda create -n tensorflow python=3.6
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.5.12
latest version: 4.6.8
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: C:\Users\admin\Anaconda3\envs\tensorflow
added / updated specs:
- python=3.6
The following packages will be downloaded:
package | build
---------------------------|-----------------
python-3.6.8 | h9f7ef89_7 20.3 MB
The following NEW packages will be INSTALLED:
certifi: 2019.3.9-py36_0
pip: 19.0.3-py36_0
python: 3.6.8-h9f7ef89_7
setuptools: 40.8.0-py36_0
sqlite: 3.27.2-he774522_0
vc: 14.1-h0510ff6_4
vs2015_runtime: 14.15.26706-h3a45250_0
wheel: 0.33.1-py36_0
wincertstore: 0.2-py36h7fe50ca_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
python-3.6.8 | 20.3 MB | ############################################8 | 23%
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda/pkgs/main/win-64/python-3.6.8-h9f7ef89_7.tar.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
解决方法:https://blog.csdn/ling_xiobai/article/details/78659981
(base) C:\WINDOWS\system32>conda config --add channels https://mirrors.tuna.tsinghua.edu/anaconda/cloud/msys2/
(base) C:\WINDOWS\system32>conda config --add channels https://mirrors.tuna.tsinghua.edu/anaconda/cloud/conda-forge/
(base) C:\WINDOWS\system32>conda config --add channels https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free/
(base) C:\WINDOWS\system32>conda config --set show_channel_urls yes
执行新建环境命令:
(base) C:\WINDOWS\system32>conda create -n tensorflow python=3.6
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.5.12
latest version: 4.6.8
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: C:\Users\admin\Anaconda3\envs\tensorflow
added / updated specs:
- python=3.6
The following packages will be downloaded:
package | build
---------------------------|-----------------
vs2015_runtime-14.0.25420 | 0 2.0 MB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
wincertstore-0.2 | py36_0 14 KB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
setuptools-36.4.0 | py36_1 534 KB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
certifi-2016.2.28 | py36_0 214 KB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
wheel-0.29.0 | py36_0 129 KB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
python-3.6.2 | 0 31.5 MB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
pip-9.0.1 | py36_1 1.7 MB https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
vc-14 | 0 703 B https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
------------------------------------------------------------
Total: 36.0 MB
The following NEW packages will be INSTALLED:
certifi: 2016.2.28-py36_0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
pip: 9.0.1-py36_1 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
python: 3.6.2-0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
setuptools: 36.4.0-py36_1 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
vc: 14-0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
vs2015_runtime: 14.0.25420-0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
wheel: 0.29.0-py36_0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
wincertstore: 0.2-py36_0 https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/free
Proceed ([y]/n)? y
Downloading and Extracting Packages
vs2015_runtime-14.0. | 2.0 MB | ################################################################################################################################################################################################# | 100%
wincertstore-0.2 | 14 KB | ################################################################################################################################################################################################# | 100%
setuptools-36.4.0 | 534 KB | ################################################################################################################################################################################################# | 100%
certifi-2016.2.28 | 214 KB | ################################################################################################################################################################################################# | 100%
wheel-0.29.0 | 129 KB | ################################################################################################################################################################################################# | 100%
python-3.6.2 | 31.5 MB | ################################################################################################################################################################################################# | 100%
pip-9.0.1 | 1.7 MB | ################################################################################################################################################################################################# | 100%
vc-14 | 703 B | ################################################################################################################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate tensorflow
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) C:\WINDOWS\system32>conda env list
# conda environments:
#
base * C:\Users\admin\Anaconda3
tensorflow C:\Users\admin\Anaconda3\envs\tensorflow
然后重新打开Anaconda Navigator ,tensorflow的环境就存在了
接下来安装tensorflow和opencv的代码:
进度条没有进度,等的实在着急,且再次报错 :Multiple Errors Encountered. 决定使用命令行安装
离线下载opencv的模块:https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
关于如何选择版本参见:https://blog.csdn/qq_34733907/article/details/86591420
进入tensorflow环境:
(base) C:\WINDOWS\system32>activate tensorflow
(tensorflow) C:\WINDOWS\system32>cd C:\Users\admin\Downloads
(tensorflow) C:\Users\admin\Downloads>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip._internal;print(pip._internal.pep425tags.get_supported())
[('cp36', 'cp36m', 'win_amd64'), ('cp36', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'), ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('py36', 'none', 'any'), ('py3', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
>>> ^Z
(tensorflow) C:\Users\admin\Downloads>pip install opencv_python-3.4.5-cp36-cp36m-win_amd64.whl
Processing c:\users\admin\downloads\opencv_python-3.4.5-cp36-cp36m-win_amd64.whl
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.5
(tensorflow) C:\Users\admin\Downloads>
配置环境变量:没有找到第三个,所以没有配置第3个
然后回到Anaconda Navigator重新安装应用,发现应用成功了
以同样的方法安装tensorflow
这样就完成了在anaconda软件中安装和配置tensorflow和opencv。
接下来安装notebook
安装完成后启动可在浏览器中操作,我的执行不了python文件,目前也用不上,不过多赘述
在命令行中执行,可以运行
说明环境没问题
(tensorflow) C:\Users\admin\Downloads>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> import tensorflow as tf
>>> hello = tf.constant("hello tf")
>>> sess = tf.Session()
2019-03-22 16:39:41.689990: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.704369: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.713365: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.723951: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.740968: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.761204: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.778492: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 16:39:41.798752: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run(hello))
b'hello tf'
>>> import cv2
>>> print("hello opencv")
hello opencv
接下来要开始复现谷歌的人脸识别算法,facenet
github上下载facenet的代码。
按照 http://wwwblogs/zyly/p/9703614.html 所述配置
1、配置Facenet环境
将facebet文件夹加到python引入库的默认搜索路径中,将facenet文件整个复制到anaconda3安装文件目录下lib\site-packages下:
然后把剪切src目录下的文件,然后删除facenet下的所有文件,粘贴src目录下的文件到facenet下,这样做的目的是为了导入src目录下的包(这样import align.detect_face不会报错)。
在Anaconda Prompt中运行python,输入import facenet,不报错即可:
上面这一步遇到的问题是一开始将src文件夹复制到Anaconda3\Lib\site-packages下了,然后import出错,应该执行如下步骤:
先使用pip show tensorflow查看模块存储路径,然后
(tensorflow) C:\Users\admin\Downloads>pip show tensorflow
Name: tensorflow
Version: 1.2.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow/
Author: Google Inc.
Author-email: opensource@google
License: Apache 2.0
Location: c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages
Requires: protobuf, markdown, wheel, six, werkzeug, backports.weakref, html5lib, numpy, bleach
Required-by:
(tensorflow) C:\Users\admin\Downloads>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import facenet
2、下载LFW数据集
接下来将会讲解如何使用已经训练好的模型在LFW(Labeled Faces in the Wild)数据库上测试,不过我还需要先来介绍一下LFW数据集。
LFW数据集是由美国马赛诸塞大学阿姆斯特分校计算机实验室整理的人脸检测数据集,是评估人脸识别算法效果的公开测试数据集。LFW数据集共有13233张jpeg格式图片,属于5749个不同的人,其中有1680人对应不止一张图片,每张图片尺寸都是250×250250×250,并且被标示出对应的人的名字。LFW数据集中每张图片命名方式为"lfw/name/name_xxx.jpg",这里"xxx"是前面补零的四位图片编号。例如,前美国总统乔治布什的第十张图片为"lfw/George_W_Bush/George_W_Bush_0010.jpg"。
数据集的下载地址为:http://vis-www.cs.umass.edu/lfw/lfw.tgz,下载完成后,解压数据集,打开打开其中一个文件夹,如下:
在lfw下新建一个文件夹raw,把lfw中所有的文件(除了raw)移到raw文件夹中。可以看到我的数据集lfw是放在datasets文件夹下,其中datasets文件夹和facenet是在同一路径下。
3、LFW数据集预处理(LFW数据库上的人脸检测和对齐)
我们需要将检测所使用的数据集校准为和训练模型所使用的数据集大小一致(160×160160×160),转换后的数据集存储在lfw_mtcnnpy_160文件夹内,
处理的第一步是使用MTCNN网络进行人脸检测和对齐,并缩放到160×160160×160。
MTCNN的实现主要在文件夹facenet/src/align中,文件夹的内容如下:
- detect_face.py:定义了MTCNN的模型结构,由P-Net、R-Net、O-Net组成,这三个网络已经提供了预训练的模型,模型数据分别对应文件det1.npy、det2.npy、det3.npy。
- align_dataset_matcnn.py:是使用MTCNN的模型进行人脸检测和对齐的入口代码。
使用脚本align_dataset_mtcnn.py对LFW数据库进行人脸检测和对齐的方法通过运行命令,我们打开Anaconda Prompt,来到facenet所在的路径下,运行如下命令:
python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
该命令会创建一个datasets/lfw/lfw_mtcnnpy_160的文件夹,并将所有对齐好的人脸图像存放到这个文件夹中,数据的结构和原先的datasets/lfw/raw一样。参数--image_size 160 --margin 32的含义是在MTCNN检测得到的人脸框的基础上缩小32像素(训练时使用的数据偏大),并缩放到160×160160×160大小,因此最后得到的对齐后的图像都是160×160160×160像素的,这样的话,就成功地从原始图像中检测并对齐了人脸。
下面我们来简略的分析一下align_dataset_mtcnn.py源文件,先上源代码如下,然后我们来解读一下main()函数
View Code
- 首先加载LFW数据集;
- 建立MTCNN网络,并预训练(即使用训练好的网络初始化参数),Google Facenet的作者在建立网络时,自己重写了CNN网络所需的各个组件,包括conv层,MaxPool层,Softmax层等等,由于作者写的比较复杂。有兴趣的同学看看MTCNN 的 TensorFlow 实现这篇博客,博主使用Keras重新实现了MTCNN网络,也比较好懂代码链接:https://github/FortiLeiZhang/model_zoo/tree/master/TensorFlow/mtcnn;
- 调用align.detect_face.detect_face()函数进行人脸检测,返回校准后的人脸边界框的位置、score、以及关键点坐标;
- 对人脸框进行处理,从原图中裁切(先进行了边缘扩展32个像素)、以及缩放(缩放到160×160160×160)等,并保存相关信息到文件;
关于人脸检测的具体细节可以查看detect_face()函数,代码也比较长,这里我放上代码,具体细节部分可以参考MTCNN 的 TensorFlow 实现这篇博客。
我的运行:
缺少了挺多模块,全部都装上
(tensorflow) G:\graduationproject\facenet>pip install scikit_learn-0.20.3-cp36-cp36m-win_amd64.whl
Processing g:\graduationproject\facenet\scikit_learn-0.20.3-cp36-cp36m-win_amd64.whl
Requirement already satisfied: scipy>=0.13.3 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from scikit-learn==0.20.3) (1.2.1)
Requirement already satisfied: numpy>=1.8.2 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from scikit-learn==0.20.3) (1.13.1)
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.20.3
(tensorflow) G:\graduationproject\facenet>pip install -i https://douban/simple h5py
Looking in indexes: https://douban/simple
Collecting h5py
Could not find a version that satisfies the requirement h5py (from versions: )
No matching distribution found for h5py
(tensorflow) G:\graduationproject\facenet>pip install -i https://douban/simple requests
Looking in indexes: https://douban/simple
Collecting requests
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple requests
Looking in indexes: https://pypi.douban/simple
Collecting requests
Downloading https://pypi.doubanio/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 2.3MB/s
Collecting certifi>=2017.4.17 (from requests)
Downloading https://pypi.doubanio/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
100% |████████████████████████████████| 163kB 7.9MB/s
Collecting idna<2.9,>=2.5 (from requests)
Downloading https://pypi.doubanio/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 6.1MB/s
Collecting urllib3<1.25,>=1.21.1 (from requests)
Downloading https://pypi.doubanio/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl (118kB)
100% |████████████████████████████████| 122kB 4.1MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Downloading https://pypi.doubanio/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 2.0MB/s
Installing collected packages: certifi, idna, urllib3, chardet, requests
Found existing installation: certifi 2016.2.28
Uninstalling certifi-2016.2.28:
Successfully uninstalled certifi-2016.2.28
Successfully installed certifi-2019.3.9 chardet-3.0.4 idna-2.8 requests-2.21.0 urllib3-1.24.1
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple psutil
Looking in indexes: https://pypi.douban/simple
Collecting psutil
Downloading https://pypi.doubanio/packages/16/6a/cc5ba8d7e3ada0d4621d493dbdcb43ed38f3549642916a14c9e070add21a/psutil-5.6.1-cp36-cp36m-win_amd64.whl (230kB)
100% |████████████████████████████████| 235kB 3.1MB/s
Installing collected packages: psutil
Successfully installed psutil-5.6.1
(tensorflow) G:\graduationproject\facenet>pip install h5py-2.9.0-cp36-cp36m-win_amd64.whl
Processing g:\graduationproject\facenet\h5py-2.9.0-cp36-cp36m-win_amd64.whl
Requirement already satisfied: six in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from h5py==2.9.0) (1.10.0)
Requirement already satisfied: numpy>=1.7 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from h5py==2.9.0) (1.13.1)
Installing collected packages: h5py
Successfully installed h5py-2.9.0
(tensorflow) G:\graduationproject\facenet>pip install Pillow-5.4.1-cp36-cp36m-win_amd64.whl
Processing g:\graduationproject\facenet\pillow-5.4.1-cp36-cp36m-win_amd64.whl
Installing collected packages: Pillow
Successfully installed Pillow-5.4.1
(tensorflow) G:\graduationproject\facenet>pip install opencv-python
Requirement already satisfied: opencv-python in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (3.4.5)
(tensorflow) G:\graduationproject\facenet>pip show tensorflow
Name: tensorflow
Version: 1.2.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow/
Author: Google Inc.
Author-email: opensource@google
License: Apache 2.0
Location: c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages
Requires: six, backports.weakref, wheel, protobuf, numpy, markdown, html5lib, werkzeug, bleach
Required-by:
(tensorflow) G:\graduationproject\facenet>pip install matplotlib-3.0.3-cp36-cp36m-win_amd64.whl
Processing g:\graduationproject\facenet\matplotlib-3.0.3-cp36-cp36m-win_amd64.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib==3.0.3)
Downloading https://files.pythonhosted/packages/de/0a/001be530836743d8be6c2d85069f46fecf84ac6c18c7f5fb8125ee11d854/pyparsing-2.3.1-py2.py3-none-any.whl (61kB)
100% |████████████████████████████████| 71kB 16kB/s
Collecting kiwisolver>=1.0.1 (from matplotlib==3.0.3)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi', port=443): Read timed out. (read timeout=15)",)': /simple/kiwisolver/
Downloading https://files.pythonhosted/packages/44/72/16630c3392eba03788ad87949390516bbc488e8e118047a3b824631d21a6/kiwisolver-1.0.1-cp36-none-win_amd64.whl (57kB)
100% |████████████████████████████████| 61kB 9.6kB/s
Requirement already satisfied: python-dateutil>=2.1 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from matplotlib==3.0.3) (2.6.1)
Requirement already satisfied: numpy>=1.10.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from matplotlib==3.0.3) (1.13.1)
Collecting cycler>=0.10 (from matplotlib==3.0.3)
Downloading https://files.pythonhosted/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from kiwisolver>=1.0.1->matplotlib==3.0.3) (36.4.0)
Requirement already satisfied: six>=1.5 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from python-dateutil>=2.1->matplotlib==3.0.3) (1.10.0)
Installing collected packages: pyparsing, kiwisolver, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-3.0.3 pyparsing-2.3.1
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 35, in <module>
import align.detect_face
ModuleNotFoundError: No module named 'align'
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple align
Looking in indexes: https://pypi.douban/simple
Collecting align
Downloading https://pypi.doubanio/packages/97/4a/c6ab8383c43b752cf2f5abc43e75408f2cb1cbc48f8d64309b90cb4a85f7/align-0.0.5.tar.gz (2.6MB)
100% |████████████████████████████████| 2.6MB 7.3MB/s
Building wheels for collected packages: align
Building wheel for align (setup.py) ... done
Stored in directory: C:\Users\admin\AppData\Local\pip\Cache\wheels\82\be\4f\b6c98df8f643d62bc9883557c993deaa0744ca379420ecf974
Successfully built align
Installing collected packages: align
Successfully installed align-0.0.5
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 35, in <module>
import align.detect_face
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\align\__init__.py", line 1, in <module>
from .prepare_transcripts import *
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\align\prepare_transcripts.py", line 7, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple pandas
Looking in indexes: https://pypi.douban/simple
Collecting pandas
Downloading https://pypi.doubanio/packages/d0/4e/9db3468e504ac9aeadb37eb32bcf0a74d063d24ad1471104bd8a7ba20c97/pandas-0.24.2-cp36-cp36m-win_amd64.whl (8.8MB)
100% |████████████████████████████████| 8.8MB 7.3MB/s
Collecting pytz>=2011k (from pandas)
Downloading https://pypi.doubanio/packages/61/28/1d3920e4d1d50b19bc5d24398a7cd85cc7b9a75a490570d5a30c57622d34/pytz-2018.9-py2.py3-none-any.whl (510kB)
100% |████████████████████████████████| 512kB 12.8MB/s
Requirement already satisfied: python-dateutil>=2.5.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from pandas) (2.6.1)
Requirement already satisfied: numpy>=1.12.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from pandas) (1.13.1)
Requirement already satisfied: six>=1.5 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.10.0)
Installing collected packages: pytz, pandas
Successfully installed pandas-0.24.2 pytz-2018.9
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 35, in <module>
import align.detect_face
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\align\__init__.py", line 1, in <module>
from .prepare_transcripts import *
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\align\prepare_transcripts.py", line 12, in <module>
import nltk
ModuleNotFoundError: No module named 'nltk'
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple nltk
Looking in indexes: https://pypi.douban/simple
Collecting nltk
Downloading https://pypi.doubanio/packages/6f/ed/9c755d357d33bc1931e157f537721efb5b88d2c583fe593cc09603076cc3/nltk-3.4.zip (1.4MB)
100% |████████████████████████████████| 1.4MB 1.5MB/s
Requirement already satisfied: six in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from nltk) (1.10.0)
Collecting singledispatch (from nltk)
Downloading https://pypi.doubanio/packages/c5/10/369f50bcd4621b263927b0a1519987a04383d4a98fb10438042ad410cf88/singledispatch-3.4.0.3-py2.py3-none-any.whl
Building wheels for collected packages: nltk
Building wheel for nltk (setup.py) ... done
Stored in directory: C:\Users\admin\AppData\Local\pip\Cache\wheels\e7\35\7a\e2b4bc80f3405208922309153f4bdbec4054840e4414ad0134
Successfully built nltk
Installing collected packages: singledispatch, nltk
Successfully installed nltk-3.4 singledispatch-3.4.0.3
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 35, in <module>
import align.detect_face
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\align\__init__.py", line 1, in <module>
from .prepare_transcripts import *
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\align\prepare_transcripts.py", line 19, in <module>
from gensim.models import word2vec
ModuleNotFoundError: No module named 'gensim'
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple gensim
Looking in indexes: https://pypi.douban/simple
Collecting gensim
Downloading https://pypi.doubanio/packages/54/ee/c1f685caa83ee9b8f54573b51648af61b01377bcc5981a18704f5247cce7/gensim-3.7.1-cp36-cp36m-win_amd64.whl (24.1MB)
100% |████████████████████████████████| 24.1MB 6.4MB/s
Requirement already satisfied: scipy>=0.18.1 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from gensim) (1.2.1)
Collecting smart-open>=1.7.0 (from gensim)
Downloading https://pypi.doubanio/packages/ff/c8/de7dcf34d4b5f2ae94fe1055e0d6418fb97a63c9dc3428edd264704983a2/smart_open-1.8.0.tar.gz (40kB)
100% |████████████████████████████████| 40kB 10.2MB/s
Requirement already satisfied: numpy>=1.11.3 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from gensim) (1.13.1)
Requirement already satisfied: six>=1.5.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from gensim) (1.10.0)
Collecting boto>=2.32 (from smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/23/10/c0b78c27298029e4454a472a1919bde20cb182dab1662cec7f2ca1dcc523/boto-2.49.0-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 6.8MB/s
Collecting bz2file (from smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/61/39/122222b5e85cd41c391b68a99ee296584b2a2d1d233e7ee32b4532384f2d/bz2file-0.98.tar.gz
Requirement already satisfied: requests in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from smart-open>=1.7.0->gensim) (2.21.0)
Collecting boto3 (from smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/02/af/b1cd14cb4b8889968c8fefdda196da7dd15562b5a3fba2201dd1bfdfab43/boto3-1.9.119-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 2.6MB/s
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from requests->smart-open>=1.7.0->gensim) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from requests->smart-open>=1.7.0->gensim) (2019.3.9)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from requests->smart-open>=1.7.0->gensim) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from requests->smart-open>=1.7.0->gensim) (3.0.4)
Collecting jmespath<1.0.0,>=0.7.1 (from boto3->smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/83/94/7179c3832a6d45b266ddb2aac329e101367fbdb11f425f13771d27f225bb/jmespath-0.9.4-py2.py3-none-any.whl
Collecting botocore<1.13.0,>=1.12.119 (from boto3->smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/eb/c6/49443633bd8e0677ece4e0605b0abcfef3f627ed9c957d0579716f2564b4/botocore-1.12.119-py2.py3-none-any.whl (5.3MB)
100% |████████████████████████████████| 5.3MB 4.7MB/s
Collecting s3transfer<0.3.0,>=0.2.0 (from boto3->smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/d7/de/5737f602e22073ecbded7a0c590707085e154e32b68d86545dcc31004c02/s3transfer-0.2.0-py2.py3-none-any.whl (69kB)
100% |████████████████████████████████| 71kB 907kB/s
Collecting docutils>=0.10 (from botocore<1.13.0,>=1.12.119->boto3->smart-open>=1.7.0->gensim)
Downloading https://pypi.doubanio/packages/36/fa/08e9e6e0e3cbd1d362c3bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl (543kB)
100% |████████████████████████████████| 552kB 10.2MB/s
Requirement already satisfied: python-dateutil<3.0.0,>=2.1; python_version >= "2.7" in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from botocore<1.13.0,>=1.12.119->boto3->smart-open>=1.7.0->gensim) (2.6.1)
Building wheels for collected packages: smart-open, bz2file
Building wheel for smart-open (setup.py) ... done
Stored in directory: C:\Users\admin\AppData\Local\pip\Cache\wheels\ff\81\c0\4b47774dd62e1c8ff9ba40b771c9ba0f76cff55806d369d41c
Building wheel for bz2file (setup.py) ... done
Stored in directory: C:\Users\admin\AppData\Local\pip\Cache\wheels\e4\0d\00\03c6e7d52a36ad95c18a9d4678f1184396e3b64ac58b008cf9
Successfully built smart-open bz2file
Installing collected packages: boto, bz2file, jmespath, docutils, botocore, s3transfer, boto3, smart-open, gensim
Successfully installed boto-2.49.0 boto3-1.9.119 botocore-1.12.119 bz2file-0.98 docutils-0.14 gensim-3.7.1 jmespath-0.9.4 s3transfer-0.2.0 smart-open-1.8.0
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 35, in <module>
import align.detect_face
ModuleNotFoundError: No module named 'align.detect_face'
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 159, in <module>
main(parse_arguments(sys.argv[1:]))
File "facenet/src/align/align_dataset_mtcnn.py", line 46, in main
facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))
AttributeError: module 'facenet' has no attribute 'store_revision_info'
出错:
第一个错误:因为detect_face.py和align_dataset_mtcnn.py在同一文件夹下,所以把align_dataset_mtcnn.py移动到上一级目录中
第二个错误:参考https://blog.csdn/weixin_42280271/article/details/82865337
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 35, in <module>
import align.detect_face
ModuleNotFoundError: No module named 'align.detect_face'
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 159, in <module>
main(parse_arguments(sys.argv[1:]))
File "facenet/src/align/align_dataset_mtcnn.py", line 46, in main
facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))
AttributeError: module 'facenet' has no attribute 'store_revision_info'
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 159, in <module>
main(parse_arguments(sys.argv[1:]))
File "facenet/src/align/align_dataset_mtcnn.py", line 46, in main
facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))
AttributeError: module 'facenet' has no attribute 'store_revision_info'
(tensorflow) G:\graduationproject\facenet>
第三个错误:卸载numpy重装:
cmd下:
安装pycurl包
pip install pycurl
列出已经安装的python包
pip list
输出pycurl包的信息
pip show pycurl
卸载pycurl包
pip uninstall pycurl
---------------------
作者:guyue35
来源:CSDN
原文:https://blog.csdn/guyue35/article/details/51337513
版权声明:本文为博主原创文章,转载请附上博文链接!
(base) C:\Users\admin>activate tensorflow
(tensorflow) C:\Users\admin>G:
(tensorflow) G:\>cd graduationproject\facenet
(tensorflow) G:\graduationproject\facenet>python facenet/src/align/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Traceback (most recent call last):
File "__init__.pxd", line 1036, in numpy.import_array
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "facenet/src/align/align_dataset_mtcnn.py", line 34, in <module>
import facenet
File "C:\Users\admin\Anaconda3\envs\tensorflow\Lib\site-packages\facenet\facenet.py", line 35, in <module>
from sklearn.model_selection import KFold
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\sklearn\base.py", line 14, in <module>
from .utils.fixes import signature
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\sklearn\utils\__init__.py", line 12, in <module>
from .murmurhash import murmurhash3_32
File "sklearn\utils\murmurhash.pyx", line 26, in init sklearn.utils.murmurhash
File "__init__.pxd", line 1038, in numpy.import_array
ImportError: numpy.core.multiarray failed to import
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple numpy
Looking in indexes: https://pypi.douban/simple
Requirement already satisfied: numpy in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (1.13.1)
(tensorflow) G:\graduationproject\facenet>pip install -i https://pypi.douban/simple numpy.core
Looking in indexes: https://pypi.douban/simple
Collecting numpy.core
Could not find a version that satisfies the requirement numpy.core (from versions: )
No matching distribution found for numpy.core
(tensorflow) G:\graduationproject\facenet>
第四个错误:
(tensorflow) G:\graduationproject\facenet>python facenet/src/align_dataset_mtcnn.py datasets/lfw/raw datasets/lfw/lfw_mtcnnpy_160 --image_size 160 --margin 32 --random_order
Creating networks and loading parameters
2019-03-22 19:40:50.322458: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.334064: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.347975: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.361151: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.380658: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.398882: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.428938: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-22 19:40:50.457522: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Traceback (most recent call last):
File "facenet/src/align_dataset_mtcnn.py", line 159, in <module>
main(parse_arguments(sys.argv[1:]))
File "facenet/src/align_dataset_mtcnn.py", line 55, in main
pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)
File "G:\graduationproject\facenet\facenet\src\align\detect_face.py", line 282, in create_mtcnn
pnet = PNet({'data':data})
File "G:\graduationproject\facenet\facenet\src\align\detect_face.py", line 73, in __init__
self.setup()
File "G:\graduationproject\facenet\facenet\src\align\detect_face.py", line 227, in setup
.softmax(3,name='prob1'))
File "G:\graduationproject\facenet\facenet\src\align\detect_face.py", line 51, in layer_decorated
layer_output = op(self, layer_input, *args, **kwargs)
File "G:\graduationproject\facenet\facenet\src\align\detect_face.py", line 210, in softmax
max_axis = tf.reduce_max(target, axis, keepdims=True)
TypeError: reduce_max() got an unexpected keyword argument 'keepdims'
解决方法:keepdims改为keep_dims
正常运行了
datasets/lfw/raw\Steve_Cutler\Steve_Cutler_0001.jpg
datasets/lfw/raw\John_Gruden\John_Gruden_0001.jpg
datasets/lfw/raw\Jose_Carreras\Jose_Carreras_0001.jpg
datasets/lfw/raw\Terry_McAuliffe\Terry_McAuliffe_0001.jpg
datasets/lfw/raw\Terry_McAuliffe\Terry_McAuliffe_0003.jpg
datasets/lfw/raw\Terry_McAuliffe\Terry_McAuliffe_0002.jpg
datasets/lfw/raw\John_Williams\John_Williams_0001.jpg
datasets/lfw/raw\Scott_Yates\Scott_Yates_0001.jpg
datasets/lfw/raw\Mark_Hurlbert\Mark_Hurlbert_0002.jpg
datasets/lfw/raw\Mark_Hurlbert\Mark_Hurlbert_0004.jpg
datasets/lfw/raw\Mark_Hurlbert\Mark_Hurlbert_0003.jpg
datasets/lfw/raw\Mark_Hurlbert\Mark_Hurlbert_0005.jpg
datasets/lfw/raw\Mark_Hurlbert\Mark_Hurlbert_0001.jpg
datasets/lfw/raw\Alex_Penelas\Alex_Penelas_0002.jpg
datasets/lfw/raw\Alex_Penelas\Alex_Penelas_0001.jpg
datasets/lfw/raw\Gina_Centrello\Gina_Centrello_0001.jpg
Total number of images: 13233
Number of successfully aligned images: 13233
用时0.5h
结果:
评估模型的准确率:
出错:
(tensorflow) G:\graduationproject\facenet\facenet>python src/validate_on_lfw.py ../datasets/lfw/lfw_mtcnnpy_160 ../models/20180408-102900
2019-03-25 11:33:58.940413: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:58.948354: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:58.962997: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:58.969602: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:58.984506: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:58.999096: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:59.015901: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2019-03-25 11:33:59.029181: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Model directory: ../models/20180408-102900
Metagraph file: model-20180408-102900.meta
Checkpoint file: model-20180408-102900.ckpt-90
Traceback (most recent call last):
File "src/validate_on_lfw.py", line 164, in <module>
main(parse_arguments(sys.argv[1:]))
File "src/validate_on_lfw.py", line 73, in main
facenet.load_model(args.model, input_map=input_map)
File "G:\graduationproject\facenet\facenet\src\facenet.py", line 381, in load_model
saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=input_map)
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\training\saver.py", line 1686, in import_meta_graph
**kwargs)
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\meta_graph.py", line 504, in import_scoped_meta_graph
producer_op_list=producer_op_list)
File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\importer.py", line 283, in import_graph_def
raise ValueError('No op named %s in defined operations.' % node.op)
ValueError: No op named DecodeBmp in defined operations.
解决方法:Anaconda中升级tensorflow的版本至1.9.0
再次执行,执行结果:
(tensorflow) G:\graduationproject\facenet\facenet>python src/validate_on_lfw.py ../datasets/lfw/lfw_mtcnnpy_160 ../models/20180408-102900
2019-03-25 16:26:12.469707: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Model directory: ../models/20180408-102900
Metagraph file: model-20180408-102900.meta
Checkpoint file: model-20180408-102900.ckpt-90
2019-03-25 16:26:52.757322: W T:\src\github\tensorflow\tensorflow\core\graph\graph_constructor:1248] Importing a graph with a lower producer version 24 into an existing graph with producer version 26. Shape inference will have run different parts of the graph with different producer versions.
Runnning forward pass on LFW images
............
Accuracy: 0.97817+-0.00502
Validation rate: 0.83967+-0.03686 @ FAR=0.00133
Area Under Curve (AUC): 0.997
Equal Error Rate (EER): 0.025
2019-03-25 17:05:57.134546: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.141375: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.150160: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.157672: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.164343: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.173664: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.184883: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:277] _2_input_producer: Skipping cancelled enqueue attempt with queue not closed
2019-03-25 17:05:57.193215: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
2019-03-25 17:05:57.204908: W T:\src\github\tensorflow\tensorflow\core\kernels\queue_base:285] _1_FIFOQueueV2: Skipping cancelled dequeue attempt with queue not closed
由此,我们验证了模型在LFW上的准确率为99.7%。
在自己的图片上应用已有模型:
(tensorflow) G:\graduationproject\facenet\facenet>python src/compare.py ../models/20180408-102900 src/img1.jpg src/img2.jpg src/img3.jpg
Creating networks and loading parameters
2019-03-25 18:48:14.200682: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Model directory: ../models/20180408-102900
Metagraph file: model-20180408-102900.meta
Checkpoint file: model-20180408-102900.ckpt-90
Images:
0: src/img1.jpg
1: src/img2.jpg
2: src/img3.jpg
Distance matrix
0 1 2
0 0.0000 0.7271 0.5981
1 0.7271 0.0000 0.6791
2 0.5981 0.6791 0.0000
(tensorflow) G:\graduationproject\facenet\facenet>python src/compare.py ../models/20180408-102900 src/img1.jpg src/img2.jpg src/img3.jpg
Creating networks and loading parameters
2019-03-25 18:55:24.259552: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Model directory: ../models/20180408-102900
Metagraph file: model-20180408-102900.meta
Checkpoint file: model-20180408-102900.ckpt-90
Images:
0: src/img1.jpg
1: src/img2.jpg
2: src/img3.jpg
Distance matrix
0 1 2
0 0.0000 0.9791 0.5981
1 0.9791 0.0000 0.8691
2 0.5981 0.8691 0.0000
版权声明:本文标题:毕设记录--环境搭建:Anaconda的安装与环境搭建 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1726378555h948471.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论