标签:efault 结果 ane turn yum源 通过 cat imp 令行
yum install -y tkinter
yum install -y tk-devel
1、下载python3并解压,参考下载地址:https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz。
2、创建文件夹/usr/local/python3.6.5
。
3、进入解压后的目录,执行如下命令:
./configure -prefix=/usr/local/python3.6.5
make
make install
cd /usr/bin
mv python python_bak_2
mv python-config python-config_bak_2
ln -s /usr/local/python3.6.5/bin/python3 /usr/bin/python
ln -s /usr/local/python3.6.5/bin/python3-config /usr/bin/python-config
python setup.py build
python setup.py install
python setup.py build
python setup.py install
cd /usr/bin
mv pip pip-bak
ln -s /usr/local/python3.6.5/bin/pip /usr/bin/pip
/usr/libexec/urlgrabber-ext-down
/usr/bin/yum-config-manager
/usr/bin/yum
将上面三个文件的第一行代码 #! /usr/bin/python
修改为 #! /usr/bin/python_bak_2
。其中 /usr/bin/python_bak_2
是之前备份的python2的命令。
cpu版本:https://download.tensorflow.google.cn/linux/cpu/tensorflow-1.5.0-cp36-cp36m-linux_x86_64.whl
gpu版本:https://download.tensorflow.google.cn/linux/gpu/tensorflow_gpu-1.5.0-cp36-cp36m-linux_x86_64.whl
注意,从tensorflow的1.6版本开始,预构建二进制文件将使用AVX指令。较早的CPU可能无法执行这些二进制文件。 如果采用了1.6或以上的版本的话,如果CPU过老,在执行 import tensorflow as tf
的时候,会抛出 非法指令(吐核)
的错误。
pip install tensorflow-1.5.0-cp36-cp36m-linux_x86_64.whl
python
进入python的命令行界面,然后输入如下代码: import tensorflow as tf
hello = tf.constant(‘Hello, TensorFlow!‘)
sess = tf.Session()
print(sess.run(hello))
如果能够正常输出,说明tensorflow安装成功。
以下操作请保证当前网络环境能够访问google。
pip install cython
pip install opencv-python
pip install matplotlib
pip install easydict
pip install Pillow
pip install scipy
voc_0712_80k-110k.tgz
(github上和代码中的链接已失效,必须从云盘上下载):https://drive.google.com/drive/folders/0B1_fAEgxdnvJeGg0LWJZZ1N2aDAtf-faster-rcnn-master/lib
目录,执行如下命令:make clean
make
cd ..
tf-faster-rcnn-master
目录下,执行如下命令:cd data
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make
cd ../../..
tf-faster-rcnn-master/tools/demo.py
,添加 一行代码 plt.switch_backend(‘agg‘)
:import _init_paths
from model.config import cfg
from model.test import im_detect
from model.nms_wrapper import nms
from utils.timer import Timer
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
import os, cv2
import argparse
from nets.vgg16 import vgg16
from nets.resnet_v1 import resnetv1
plt.switch_backend(‘agg‘) # 这里是需要添加的代码
CLASSES = (‘__background__‘,
‘aeroplane‘, ‘bicycle‘, ‘bird‘, ‘boat‘,
‘bottle‘, ‘bus‘, ‘car‘, ‘cat‘, ‘chair‘,
‘cow‘, ‘diningtable‘, ‘dog‘, ‘horse‘,
tf-faster-rcnn-master/lib/model/nms_wrapper.py
,修改如下:from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from model.config import cfg
# from nms.gpu_nms import gpu_nms # 注释掉这一行
from nms.cpu_nms import cpu_nms
def nms(dets, thresh, force_cpu=False):
"""Dispatch to either CPU or GPU NMS implementations."""
if dets.shape[0] == 0:
return []
# if cfg.USE_GPU_NMS and not force_cpu: # 注释掉这一行
# return gpu_nms(dets, thresh, device_id=0) # 注释掉这一行
# else: # 注释掉这一行
return cpu_nms(dets, thresh) # 该行顶格
tf-faster-rcnn-master/lib/model/config.py
,修改一行代码:# Use GPU implementation of non-maximum suppression
__C.USE_GPU_NMS = False # 将原本的 True 修改为 False
tf-faster-rcnn-master/lib/setup.py
,注释如下语句: ···
# CUDA = locate_cuda() # 注释掉这一行
···
# self.src_extensions.append(‘.cu‘) # 注释掉这一行
···
) # 这里有个逗号需要删除
# Extension(‘nms.gpu_nms‘, # 注释掉这一行
# [‘nms/nms_kernel.cu‘, ‘nms/gpu_nms.pyx‘], # 注释掉这一行
# library_dirs=[CUDA[‘lib64‘]], # 注释掉这一行
# libraries=[‘cudart‘], # 注释掉这一行
# language=‘c++‘, # 注释掉这一行
# runtime_library_dirs=[CUDA[‘lib64‘]], # 注释掉这一行
# this syntax is specific to this build system
# we‘re only going to use certain compiler args with nvcc and not with gcc
# the implementation of this trick is in customize_compiler() below
# extra_compile_args={‘gcc‘: ["-Wno-unused-function"], # 注释掉这一行
# ‘nvcc‘: [‘-arch=sm_52‘, # 注释掉这一行
# ‘--ptxas-options=-v‘, # 注释掉这一行
# ‘-c‘, # 注释掉这一行
# ‘--compiler-options‘, # 注释掉这一行
# "‘-fPIC‘"]}, # 注释掉这一行
# include_dirs = [numpy_include, CUDA[‘include‘]] # 注释掉这一行
# ) # 注释掉这一行
tf-faster-rcnn-master
目录下,执行如下命令:mkdir -p output/res101/voc_2007_trainval+voc_2012_trainval/default
然后将模型 voc_0712_80k-110k.tgz
进行解压,把解压后的四个文件放到刚刚创建好的目录中,完成后的结构如下:
[root@node68 default]# pwd
/opt/tensorflow/tf-faster-rcnn-master/output/res101/voc_2007_trainval+voc_2012_trainval/default
[root@node68 default]# ls
res101_faster_rcnn_iter_110000.ckpt.data-00000-of-00001 res101_faster_rcnn_iter_110000.ckpt.meta
res101_faster_rcnn_iter_110000.ckpt.index res101_faster_rcnn_iter_110000.pkl
[root@node68 default]#
tf-faster-rcnn-master/tools/demo.py
文件,添加一行代码,这样可以生成结果文件图片:···
plt.axis(‘off‘)
plt.tight_layout()
plt.draw()
plt.savefig("/opt/{}.png".format(class_name)) # 添加一行代码,具体的可以自己定义文件名称
def demo(sess, net, image_name):
"""Detect object classes in an image using pre-computed object proposals."""
···
tf-faster-rcnn-master
目录下,执行如下命令: ./tools/demo.py
程序开始使用现有的模型对目录中的测试图片进行标记:
[root@node68 tf-faster-rcnn-master]# ./tools/demo.py
/opt/tensorflow/tf-faster-rcnn-master
Loaded network output/res101/voc_2007_trainval+voc_2012_trainval/default/res101_faster_rcnn_iter_110000.ckpt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000456.jpg
Detection took 28.165s for 300 object proposals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000542.jpg
···
CentOS7.5下安装tensorflow和运行tf-faster-rcnn
标签:efault 结果 ane turn yum源 通过 cat imp 令行
原文地址:https://www.cnblogs.com/shenggang/p/9643753.html