TensorFlow年齡識別演示例子
代碼源
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 <module>
from utils import ImageCoder, make_batch, FaceDetector
File "/home/david/work/tensorflow/rude-carnie/utils.py", line 7, in <module>
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
運行結果
~/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