linux 运行 AI模型

代码源

https://github.com/dpressel/rude-carnie

跑这个例子如果是英文不熟,可以异步中文版,有测试图片

https://github.com/nanpian/rude-carnie

模型下载

You can find a pre-trained age checkpoint for inception here:https://drive.google.com/drive/folders/0B8N1oYmGLVGWbDZ4Y21GLWxtV1E 因为被墙,在这提供百度网盘下载链接,下载后解压到本地工程里面的22801目录 http://pan.baidu.com/s/1mhLBIHy

运行步骤

python2.7 guess.py --model_type inception --model_dir ./22801 --filename test1.jpg

test1.jpg是拍的人像数据 需要安装python2.7、openCV3.0、tensorFlow1.0环境。 Ubuntu环境为14.04LTS 如果没有安装openCV环境,则会出现以下问题:

  Traceback (most recent call last):
      File "guess.py", line 12, in 
      from utils import ImageCoder, make_batch, FaceDetector
      File "/home/david/work/tensorflow/rude-carnie/utils.py", line 7, in 
      import cv2
      ImportError: No module named cv2

安装openCV

下载地址https://codeload.github.com/Itseez/opencv/zip/3.0.0 主要安装步骤参考http://www.cnblogs.com/asmer-stone/p/4592421.html

wget https://codeload.github.com/Itseez/opencv/zip/3.0.0

unzip opencv3.0.0

yum -y update

yum search vim

yum groupinstall "Development Tools"
1 sudo apt-get install build-essential
2 sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
3 sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

运行结果

~/work/tensorflow/rude-carnie$ python2.7 guess.py --model_type inception --model_dir ./22801 --filename   test1.jpg 
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc: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.
W tensorflow/core/platform/cpu_feature_guard.cc: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.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
Executing on /cpu:0
selected (fine-tuning) inception model
./22801/checkpoint-14999
Running file test1.jpg
Running multi-cropped image
Guess @ 1 (4, 6), prob = 0.99
Guess @ 2 (8, 12), prob = 0.01

--------------------- 本文来自 nanjingdreamfly 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/nanjingdreamfly/article/details/60141087?utm_source=copy

 

安装tensorflow

 sudo apt-get update

 sudo apt-get install python2.7-dev

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py   # 下载安装脚本
$ sudo python get-pip.py    # 运行安装脚本

sudo pip install numpy

 

pip2.7 install tensorflow==1.0.0

安装tensorflow失败:

Installing collected packages: numpy, protobuf, tensorflow
  Found existing installation: numpy 1.8.2
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.


--apt remove python-numpy

 

Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine

---解决方法:

sudo pip install six --upgrade --ignore-installed six

2、上传本地文件到服务器
scp /path/filename username@servername:/path   

例如scp /var/www/test.php [email protected]:/var/www/  #把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中

 

 

 

你可能感兴趣的:(软件安装)