Python-TensorFlow实现的人脸性别年龄识别


TensorFlow实现的人脸性别/年龄识别
资源截图
代码片段和文件信息
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License Version 2.0 (the “License“);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing software
# distributed under the License is distributed on an “AS IS“ BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

“““Converts MNIST data to TFRecords file format with Example protos.“““
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse
import os
import sys
from datetime import datetime
from scipy.io import loadmat

import tensorflow as tf

from imutils.face_utils import FaceAligner
from imutils.face_utils import rect_to_bb
import argparse
import imutils
import dlib
import cv2
import pandas as pd
import numpy as np
import skimage.io as io
from tqdm import tqdm

from sklearn.model_selection import train_test_split
FLAGS = None

def _int64_feature(value):
    return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))


def _bytes_feature(value):
    return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))


def convert_to(data_set name):
    “““Converts a dataset to tfrecords.“““
    file_name = data_set.file_name
    genders = data_set.gender
    ages = data_set.age
    face_score = data_set.score
    second_face_score = data_set.second_score
    num_examples = data_set.shape[0]
    base_dir = “data/imdb_crop“

    # initialize dlib‘s face detector (HOG-based) and then create
    # the facial landmark predictor and the face aligner
    shape_predictor = ‘shape_predictor_68_face_landmarks.dat‘
    detector = dlib.get_frontal_face_detector()
    predictor = dlib.shape_predictor(shape_predictor)
    fa = FaceAligner(predictor desiredFaceWidth=64)

    error=0
    total=0
    # if images.shape[0] != num_examples:
    #     raise ValueError(‘Images size %d does not match label size %d.‘ %
    #                      (images.shape[0] num_examples))
    # rows = images.shape[1]
    # cols = images.shape[2]
    # depth = images.shape[3]

    filename = os.path.join(name + ‘.tfrecords‘)
    print(‘Writing‘ filename)
    with tf.python_io.TFRecordWriter(filename) as writer:
        for index in tqdm(range(num_examples)):
            if face_score[index] < 0.75:
                continue
            # if (~np.isnan(second_face_score[index])) and second_face_score[index] > 0.0:
            #     continue
            if ~(0 <= ages[index] <= 100):
                continue

            if np.isnan(genders[index]):
                continue

            try:
                # image_raw = io.imread(o

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-06 12:15  Age-Gender-Estimate-TF-master
     文件        1063  2018-03-06 12:15  Age-Gender-Estimate-TF-masterLICENSE
     文件        5920  2018-03-06 12:15  Age-Gender-Estimate-TF-masterREADME.md
     文件        6930  2018-03-06 12:15  Age-Gender-Estimate-TF-masterconvert_to_records.py
     文件       10643  2018-03-06 12:15  Age-Gender-Estimate-TF-masterconvert_to_records_multiCPU.py
     文件        4926  2018-03-06 12:15  Age-Gender-Estimate-TF-masterdemo.py
     目录           0  2018-03-06 12:15  Age-Gender-Estimate-TF-masterdemo
     文件     1119763  2018-03-06 12:15  Age-Gender-Estimate-TF-masterdemodemo.gif
     文件      218316  2018-03-06 12:15  Age-Gender-Estimate-TF-masterdemodemo.jpg
     文件       58018  2018-03-06 12:15  Age-Gender-Estimate-TF-masterdemodemo1.jpg
     文件       29944  2018-03-06 12:15  Age-Gender-Estimate-TF-masterdemodemo2.jpg
     文件        4903  2018-03-06 12:15  Age-Gender-Estimate-TF-mastereval.py
     文件       12956  2018-03-06 12:15  Age-Gender-Estimate-TF-masterinception_resnet_v1.py
     文件        9063  2018-03-06 12:15  Age-Gender-Estimate-TF-masterinception_resnet_v1.pyc
     文件        5527  2018-03-06 12:15  Age-Gender-Estimate-TF-masterinspect_checkpoint.py
     文件      370329  2018-03-06 12:15  Age-Gender-Estimate-TF-masterlibboost_python.so.1.65.1
     文件        1316  2018-03-06 12:15  Age-Gender-Estimate-TF-mastermodel_transfer.py
     目录           0  2018-03-06 12:15  Age-Gender-Estimate-TF-mastermodels
     文件           0  2018-03-06 12:15  Age-Gender-Estimate-TF-mastermodelsPut pretrained model here
     文件        5553  2018-03-06 12:15  Age-Gender-Estimate-TF-masterprint_parameter.ipynb
     文件       47396  2018-03-06 12:15  Age-Gender-Estimate-TF-master
ead_images.ipynb
     文件       19029  2018-03-06 12:15  Age-Gender-Estimate-TF-master
esnet_model.py
     文件        1658  2018-03-06 12:15  Age-Gender-Estimate-TF-mastersaved_model.py
     文件    99693937  2018-03-06 12:15  Age-Gender-Estimate-TF-mastershape_predictor_68_face_landmarks.dat
     文件        6492  2018-03-06 12:15  Age-Gender-Estimate-TF-master est.py
     文件        7643  2018-03-06 12:15  Age-Gender-Estimate-TF-master rain.py
     目录           0  2018-03-06 12:15  Age-Gender-Estimate-TF-master rain_log
     文件      107935  2018-03-06 12:15  Age-Gender-Estimate-TF-master rain_log rain_log.jpg
     文件        4638  2018-03-06 12:15  Age-Gender-Estimate-TF-masterutils.py

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)