2. 安装Anaconda3-4.3.1-Windows-x86_64,默认Python版本为3.6
3. 安装完以后,打开Anaconda Prompt,输入清华的仓库镜像,更新包更快:
conda config --add channelshttps://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
4. 建立TensorFlow空间:conda create -n tensorflow python=3.5,设置Python版本为3.5
5. 激活TensorFlow空间:activate tensorflow
6. 安装TensorFlow:pip install--ignore-installed --upgrade tensorflow_gpu-1.0.0-cp35-cp35m-win_amd64.whl
7. 测试TensorFlow:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
设置SSD运行环境
1. 安装numpy(anaconda 离线安装):pipinstall numpy-1.12.1-cp35-none-win_amd64.whl
2. 安装matplotlib(anaconda 离线安装):pipinstall matplotlib-2.0.1-cp35-cp35m-win_amd64.whl
3. 安装opencv(离线):anaconda中安装:pipinstall opencv_python-3.2.0+contrib-cp35-cp35m-win_amd64.whl
4. 下载TensorFlow版本的SSD:git clone https://github.com/balancap/SSD-Tensorflow.git,或者下载压缩包解压
5. 解压TensorFlowssd目录下的/checkpoint里的ssd_300_vgg.ckpt.zip,得到模型参数
6. 安装pycharm-community-2017.1.2.exe,python编辑器,File->Setting->Project:Python->ProjectInterpreter:修改Python版本到TensorFlow工作空间下的python
7. 在notebook下新建工程,新建test_ssd.py文件
8. 在pycharm中打开ssd_notebook.ipynb,复制非注释的内容至test_ssd.py下
9. 修改test_ssd.py:
# Test on some demoimage and visualize output.
#path = '../demo/'
#image_names = sorted(os.listdir(path))
#print(image_names)
#for it in image_names:
cam=cv2.VideoCapture(0)
success, img = cam.read()
while success:
#img = cv2.imread(path+it)#mpimg.imread(path + it)
t1=cv2.getTickCount()
rclasses, rscores, rbboxes = process_image(img)
visualization.bboxes_draw_on_img(img,rclasses, rscores, rbboxes, visualization.colors_plasma)
t2=cv2.getTickCount()
print('time consumption:%.3f ms'%(1000*(t2-t1)/cv2.getTickFrequency()))
cv2.imshow('test',img)
c=cv2.waitKey(1)
if c==27:
break
# visualization.bboxes_draw_on_img(img, rclasses,rscores, rbboxes, visualization.colors_plasma)
#visualization.plt_bboxes(img, rclasses,rscores, rbboxes)
success, img = cam.read()
10. 运行程序test_ssd.py
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)