目的
使用tensorflow训练集通过人脸识别年龄
源代码
参考了博主的源码 http://blog.csdn.net/u014365862/article/details/53869712
训练集地址
import os
import glob
import tensorflow as tf
from tensorflow.contrib.layers import *
from tensorflow.contrib.slim.python.slim.nets.inception_v3 import inception_v3_base
import numpy as np
from random import shuffle
age_table=['(0, 2)','(4, 6)','(8, 12)','(15, 20)','(25, 32)','(38, 43)','(48, 53)','(60, 100)']
sex_table=['f','m'] # f:女; m:男
# AGE==True 训练年龄模型,False,训练性别模型
AGE = True
if AGE == True:
lables_size = len(age_table) # 年龄
else:
lables_size = len(sex_table) # 性别
face_set_fold = 'AdienceBenchmarkOfUnfilteredFacesForGenderAndAgeClassification'
fold_0_data = os.path.join(face_set_fold, 'fold_0_data.txt')
fold_1_data = os.path.join(face_set_fold, 'fold_1_data.txt')
fold_2_data = os.path.join(face_set_fold, 'fold_2_data.txt')
fold_3_data = os.path.join(face_set_fold, 'fold_3_data.txt')
fold_4_data = os.path.join(face_set_fold, 'fold_4_data.txt')
face_image_set = os.path.join(face_set_fold, 'aligned')
def parse_data(fold_x_data):
data_set = []
with open(fold_x_data, 'r') as f:
line_one = True
for line in f:
tmp = []
if line_one == True:
line_one = False