当前位置: 首页 > 工具软件 > ImageAI > 使用案例 >

python安装imageai库方法_小白对 imageAI环境搭建 实现object detection 的初使用(自己所用)...

陆俊智
2023-12-01

小白对 imageAI环境搭建 实现object detection 的初使用(自己所用)

第一步 下载并安装anaconda(略)

第二步 下载并安装 pycharm(略)

第三步 开始配置 安装imageAI

具体步骤如下:

打开anaconda prompt

生成.condorc

`conda config``

打开.condorc文件

conda config --show-sources

输入镜像源

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes)

或清华镜像源(我用的这个)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes

额外的源 (我没用)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

删除镜像源命令(有删除操作可用)

conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

创建虚拟环境

(如 imageai 名字任意)

conda create --name imageai python=3.5

进入创建的环境

activate imageai

查看目前已存在的环境

`(imageai) C:\Users\86166>conda info --envs

conda environments:

base D:\Anaconda3

imageai * D:\Anaconda3\envs\imageai(*表示目前在这个环境中)`

查看可以安装的tensorflow版本

conda search --full-name tensorflow

安装tensorflow==2.1.0 版本(可任意版本)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==2.1.0

卸载命令(想卸载时可用)

pip uninstall tensorflow==2.1.0

升级·

pip3 install --upgrade tensorflow

重新装 (我是装了2.1.0版本出错了,于是卸了重装了)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.15.0

测试tensorflow 是否安装成功

进入 python

输入

import tensorflow as tf

2020-06-18 15:54:20.169374: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library ‘cudart64_100.dll’; dlerror: cudart64_100.dll not found

2020-06-18 15:54:20.173292: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

(不是gpu版的忽略)

import tensorflow as tf

tf.version

‘1.15.0’

tf.path

[‘D:\Anaconda3\envs\imageai\lib\site-packages\tensorflow_core\python\keras\api\_v1’, ‘D:\Anaconda3\envs\imageai\lib\site-packages\tensorflow_estimator\python\estimator\api\_v1’, ‘D:\Anaconda3\envs\imageai\lib\site-packages\tensorflow_core’, ‘D:\Anaconda3\envs\imageai\lib\site-packages\tensorflow_core\_api\v1’]

不出错表示安装成功

成功安装tensorflow后

安装numpy pip3 install numpy

(imageai) C:\Users\86166>pip3 install numpy Requirement already satisfied: numpy in d:\anaconda3\envs\imageai\lib\site-packages (1.18.5)

安装scipy pip3 install scipy

(imageai) C:\Users\86166>pip3 install scipy Requirement already satisfied: scipy in d:\anaconda3\envs\imageai\lib\site-packages (1.4.1) Requirement already satisfied: numpy>=1.13.3 in d:\anaconda3\envs\imageai\lib\site-packages (from scipy) (1.18.5)

安装opencv-python

(imageai) C:\Users\86166>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

Collecting opencv-python

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d8/80/678757253625e7366b1ec3992b32c61223d2b8d3e5e48f63e2b2b6921bc4/opencv_python-4.2.0.34-cp35-cp35m-win_amd64.whl (33.1 MB)

|████████████████████████████████| 33.1 MB 3.3 MB/s

Requirement already satisfied: numpy>=1.11.1 in d:\anaconda3\envs\imageai\lib\site-packages (from opencv-python) (1.18.5)

Installing collected packages: opencv-python

Successfully installed opencv-python-4.2.0.34

安装Pillow pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow

(imageai) C:\Users\86166>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pillow Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bb/f7/d644a9a65a25ff0bf43b7f69ce3ef9803742a5d6e438ddfc7e925c007e6c/Pillow-7.1.2-cp35-cp35m-win_amd64.whl (2.0 MB) |████████████████████████████████| 2.0 MB ... Installing collected packages: pillow Successfully installed pillow-7.1.2

安装Matplotlib pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib

(imageai) C:\Users\86166>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting matplotlib Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c9/1e/0cf26e92de5438d0f2118435476665aae843002f4701da296b0b3252a237/matplotlib-3.0.3-cp35-cp35m-win_amd64.whl (9.1 MB) |████████████████████████████████| 9.1 MB 6.4 MB/s Collecting cycler>=0.10 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl (6.5 kB) Requirement already satisfied: numpy>=1.10.0 in d:\anaconda3\envs\imageai\lib\site-packages (from matplotlib) (1.18.5) Collecting python-dateutil>=2.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB) |████████████████████████████████| 227 kB 6.4 MB/s Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67 kB) |████████████████████████████████| 67 kB 1.1 MB/s Collecting kiwisolver>=1.0.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e8/27/74677003aecfc85421f6b70db3e49b52e65f6497a5f2faf4e345588b3c61/kiwisolver-1.1.0-cp35-none-win_amd64.whl (57 kB) |████████████████████████████████| 57 kB 1.5 MB/s Requirement already satisfied: six in d:\anaconda3\envs\imageai\lib\site-packages (from cycler>=0.10->matplotlib) (1.15.0) Requirement already satisfied: setuptools in d:\anaconda3\envs\imageai\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (47.3.1) Installing collected packages: cycler, python-dateutil, pyparsing, kiwisolver, matplotlib Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.0.3 pyparsing-2.4.7 python-dateutil-2.8.1

安装h5py pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple h5py

(imageai) C:\Users\86166>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple h5py Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: h5py in d:\anaconda3\envs\imageai\lib\site-packages (2.10.0) Requirement already satisfied: six in d:\anaconda3\envs\imageai\lib\site-packages (from h5py) (1.15.0) Requirement already satisfied: numpy>=1.7 in d:\anaconda3\envs\imageai\lib\site-packages (from h5py) (1.18.5)

安装keras

(imageai) C:\Users\86166>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple keras

最后安装 imageai

(imageai) C:\Users\86166>pip3 install https://github.com/OlafenwaMoses/ImageAI/releases/download/2.1.0/imageai-2.1.0-py3-none-any.whl

Collecting imageai2.1.0

Downloading https://github.com/OlafenwaMoses/ImageAI/releases/download/2.1.0/imageai-2.1.0-py3-none-any.whl (182 kB)

|████████████████████████████████| 182 kB 20 kB/s

Requirement already satisfied: pillow in d:\anaconda3\envs\imageai\lib\site-packages (from imageai2.1.0) (7.1.2)

Requirement already satisfied: h5py in d:\anaconda3\envs\imageai\lib\site-packages (from imageai2.1.0) (2.10.0)

Requirement already satisfied: scipy in d:\anaconda3\envs\imageai\lib\site-packages (from imageai2.1.0) (1.4.1)

Requirement already satisfied: matplotlib in d:\anaconda3\envs\imageai\lib\site-packages (from imageai2.1.0) (3.0.3)

Requirement already satisfied: numpy in d:\anaconda3\envs\imageai\lib\site-packages (from imageai2.1.0) (1.18.5)

Requirement already satisfied: six in d:\anaconda3\envs\imageai\lib\site-packages (from h5py->imageai2.1.0) (1.15.0)

Requirement already satisfied: python-dateutil>=2.1 in d:\anaconda3\envs\imageai\lib\site-packages (from matplotlib->imageai2.1.0) (2.8.1)

Requirement already satisfied: cycler>=0.10 in d:\anaconda3\envs\imageai\lib\site-packages (from matplotlib->imageai2.1.0) (0.10.0)

Requirement already satisfied: kiwisolver>=1.0.1 in d:\anaconda3\envs\imageai\lib\site-packages (from matplotlib->imageai2.1.0) (1.1.0)

Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in d:\anaconda3\envs\imageai\lib\site-packages (from matplotlib->imageai2.1.0) (2.4.7)

Requirement already satisfied: setuptools in d:\anaconda3\envs\imageai\lib\site-packages (from kiwisolver>=1.0.1->matplotlib->imageai2.1.0) (47.3.1)

Installing collected packages: imageai

Successfully installed imageai-2.1.0

安装成功

查看已经安装命令 conda list

(imageai) C:\Users\86166>conda list

packages in environment at D:\Anaconda3\envs\imageai:

Name Version Build Channel

absl-py 0.9.0 pypi_0 pypi

astor 0.8.1 pypi_0 pypi

astunparse 1.6.3 pypi_0 pypi

cachetools 4.1.0 pypi_0 pypi

certifi 2020.4.5.2 pypi_0 pypi

chardet 3.0.4 pypi_0 pypi

cycler 0.10.0 pypi_0 pypi

gast 0.3.3 pypi_0 pypi

google-auth 1.17.2 pypi_0 pypi

google-auth-oauthlib 0.4.1 pypi_0 pypi

google-pasta 0.2.0 pypi_0 pypi

grpcio 1.29.0 pypi_0 pypi

h5py 2.10.0 pypi_0 pypi

idna 2.9 pypi_0 pypi

imageai 2.1.0 pypi_0 pypi

importlib-metadata 1.6.1 pypi_0 pypi

keras 2.4.0 pypi_0 pypi

keras-applications 1.0.8 pypi_0 pypi

keras-preprocessing 1.1.2 pypi_0 pypi

kiwisolver 1.1.0 pypi_0 pypi

markdown 3.2.2 pypi_0 pypi

matplotlib 3.0.3 pypi_0 pypi

numpy 1.18.5 pypi_0 pypi

oauthlib 3.1.0 pypi_0 pypi

opencv-python 4.2.0.34 pypi_0 pypi

opt-einsum 3.2.1 pypi_0 pypi

pillow 7.1.2 pypi_0 pypi

pip 20.1.1 pypi_0 pypi

protobuf 3.12.2 pypi_0 pypi

pyasn1 0.4.8 pypi_0 pypi

pyasn1-modules 0.2.8 pypi_0 pypi

pyparsing 2.4.7 pypi_0 pypi

python 3.5.4 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

python-dateutil 2.8.1 pypi_0 pypi

pyyaml 5.3.1 pypi_0 pypi

requests 2.24.0 pypi_0 pypi

requests-oauthlib 1.3.0 pypi_0 pypi

rsa 4.6 pypi_0 pypi

scipy 1.4.1 pypi_0 pypi

setuptools 47.3.1 pypi_0 pypi

six 1.15.0 pypi_0 pypi

tensorboard 2.2.2 pypi_0 pypi

tensorboard-plugin-wit 1.6.0.post3 pypi_0 pypi

tensorflow 2.2.0 pypi_0 pypi

tensorflow-estimator 2.2.0 pypi_0 pypi

termcolor 1.1.0 pypi_0 pypi

urllib3 1.25.9 pypi_0 pypi

vc 14 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

vs2015_runtime 14.0.25420 0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

werkzeug 1.0.1 pypi_0 pypi

wheel 0.29.0 py35_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

wincertstore 0.2 py35_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free

wrapt 1.12.1 pypi_0 pypi

zipp 1.2.0 pypi_0 pypi

安装相关命令

#查看版本号

conda list keras

#查看conda库可用资源

anaconda search -t conda keras

#指定来源下载安装,https:XXXXX是指定来源

conda install -c https:XXXXX keras

在下载 tensorflow 时遇到错误

Cache entry deserialization failed, entry ignored

即更新pip

python -m pip install --upgrade pip

原文链接:https://blog.csdn.net/liushanshanshan/article/details/106901635

 类似资料: