GithubHelp home page GithubHelp logo

agegenderdeeplearning's Introduction

AgeGenderDeepLearning

Description

The purpose of this repository is to assist readers in reproducing our results on age and gender classification for facial images as described in the following work:

Gil Levi and Tal Hassner, Age and Gender Classification Using Convolutional Neural Networks, IEEE Workshop on Analysis and Modeling of Faces and Gestures (AMFG), at the IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), Boston, June 2015

Project page: http://www.openu.ac.il/home/hassner/projects/cnn_agegender/

The code contains the original meta-data files with age and gender labels, a python script for creating prototxt file in order to create the lmdb's for training and shell files for creating the lmdb and mean images.



We have also uploaded an ipython notetebook with example usage of our emotion classification networks from our paper:

Gil Levi and Tal Hassner, Emotion Recognition in the Wild via Convolutional Neural Networks and Mapped Binary Patterns, Proc. ACM International Conference on Multimodal Interaction (ICMI), Seattle, Nov. 2015

If you find our models or code useful, please add suitable reference to our paper in your work.

Also see TensorFlow implementation of our work by Rude Carnie: https://github.com/dpressel/rude-carnie


Copyright 2015, Gil Levi and Tal Hassner

The SOFTWARE provided in this page is provided "as is", without any guarantee made as to its suitability or fitness for any particular use. It may contain bugs, so use of this tool is at your own risk. We take no responsibility for any damage of any sort that may unintentionally be caused through its use.

agegenderdeeplearning's People

Contributors

bryant1410 avatar gillevi avatar gillevi100 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agegenderdeeplearning's Issues

How to affine the image?

As mentioned in your paper, you use adience_align to align the faces. So can you briefly explain the alignment setting. Just like how big the face in the image.

Is Torch faster than Caffe?

Hi,

I am using the gender detection model in Torch and in Caffe for detection from live camera.

Running the code on CPU and keeping the same models file, I am getting different prediction times.
For Caffe, it is ~1.30 seconds per frame.
For Torch, it is ~0.45 seconds per frame.

What could be the possible reason for the time difference? Is Torch faster than Caffe?

Run in VS2015(c++) ERROR

@GilLevi Hi ,
my system is win10,caffe ,cuda8.0,cudnn5.1,VS2015
I run in the VS2015 with code of “https://github.com/eveningglow/age-and-gender-classification” the error is : (I download your model)
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0427 15:50:01.427271 16228 common.cpp:36] System entropy source not available, using fallback algorithm to generate seed instead.
[libprotobuf ERROR C:\Users\guillaume\work\caffe-builder\build_v140_x64\packages\protobuf\protobuf_download-prefix\src\protobuf_download\src\google\protobuf\text_format.cc:298] Error parsing text-format caffe.NetParameter: 2:1: Invalid control characters encountered in text.
[libprotobuf ERROR C:\Users\guillaume\work\caffe-builder\build_v140_x64\packages\protobuf\protobuf_download-prefix\src\protobuf_download\src\google\protobuf\text_format.cc:298] Error parsing text-format caffe.NetParameter: 2:10: Invalid control characters encountered in text.
[libprotobuf ERROR C:\Users\guillaume\work\caffe-builder\build_v140_x64\packages\protobuf\protobuf_download-prefix\src\protobuf_download\src\google\protobuf\text_format.cc:298] Error parsing text-format caffe.NetParameter: 2:11: Interpreting non ascii codepoint 177.
[libprotobuf ERROR C:\Users\guillaume\work\caffe-builder\build_v140_x64\packages\protobuf\protobuf_download-prefix\src\protobuf_download\src\google\protobuf\text_format.cc:298] Error parsing text-format caffe.NetParameter: 2:11: Message type "caffe.NetParameter" has no field named "CaffeNet".
F0427 15:50:02.432113 16228 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: gender_net.caffemodel
*** Check failure stack trace: ***

First Conv Layer Output Error

Thank you for publishing your code. When I was running the code, I got an error regarding invalid index 4, out of bounds.
Screenshot from 2024-03-28 00-41-23
If anyone knows a fix for this, please let me know.

Random age and gender predictions

Hi,

Thanks for making such an awesome project.

I got all the setup and everything working on my Mac book pro running el Capitan. I predicted the example image which is "example_image.jpg" and it gave out the correct result (Female and age group -0,2).

But I was trying to predict some other images which I googled and the results are kind of inconsistent. Is there something which I am missing ? Should the input images be of a particular resolution or are there any constraints that must be met on the input image that needs to be predicted?

I am attaching the image which I tried to predict along with the console log

oldman

out.txt

Mean shape incompatible with input shape

Hello Gil,

Firstly, thank you for this project. This has been very helpful. :)

I have been running this bit of code:

gender_net_pretrained='./gender_net.caffemodel' gender_net_model_file='./deploy_gender.prototxt' gender_net = caffe.Classifier(gender_net_model_file, gender_net_pretrained, mean=mean, channel_swap=(2,1,0), raw_scale=255, image_dims=(256, 256))

and it throws an error saying " Mean shape incompatible with input shape".

May you please let me know why this might be happening? And a solution around this?

Thanks in advance.
Regards,
Punit.

Unbalanced accuracy among folds?

Hi, I'm experimenting with my own CNN for age recognition and I'm wondering whether it is normal to get very different validation accuracy values for the different folds?
For example, I get:
Fold 0 as test set: 55%
Fold 1 as test set: 38%
Fold 2 as test set: 50%
Fold 3 as test set: 44%
Fold 4 as test set: 47%

Is it normal to get such unbalanced results? Or could it be a bug in my data loading code since I'm not using any of your code so far.

Thanks a lot!

How to train multiple folds?

Hello,
I am new to CNN and caffe. How should I be training on multiple folds? For training the first fold, I used ./build/tools/caffe train --solver=/home/ubuntu/gender-classification/gender_net_definitions/solver_test_fold_is_0.prototxt --gpu 0
But after training with the first fold successfully, how should I proceed with the others.
Thank you in advance.

Mean shape

When I try to run the code from the notebook, I get the following error

ValueError: Mean shape incompatible with input shape.

which suggests that the mean array needs to be reshaped for input into caffe.Classifier. Any suggestions on how to proceed?

Gender missclassification

Hi Gil,

I'm trying to predict gender with your gender model. I have a bunch of images and their true classifications.
I'm predicting gender with your model and get something like 30% failure.

This is how I predict a single image:
input_image=caffe.io.load_image(image_path)
input_image = skimage.transform.resize(input_image, (256, 256))
imgplot = plt.imshow(input_image) // I'm able to see the image and it looks fine
pred=gender_net.predict([input_image])

I get the same results also without resizing.
Am I missing something?

Thanks,
Adel

Please help me to improve performance

@GilLevi
I am detecting gender/age from the video, and some faces aren't working well.
Here are sample images(you could see the age at the end of file name)

male_0_2
Male, (0, 2)

1506005830019_hkc213254dfead43_0 06_male_ 0 2

(Male, (0, 2))

1506005307778_hkc213254dfead43_23 41_male_ 0 2

(Male, (0, 2))

1506006046966_hkc213254dfeaab1_17 79_male_ 4 6

(Male, (4, 6))

1506006314181_hkc213254dfeaab1_1 92_female_ 0 2

(Female, (0, 2))

Any suggestion to improve performance?

Do I crop images too large?
Do I need to rotate image before getting age?

Thanks!

order of mean

What's the order of the mean.binaryblob? Is the order RGB or BGR? The confusion is from these lines in the demo code:
The image is read by

caffe.io.load_image(example_image)

The resulting matrix is in RGB order with value ranges from 0 to 1.

In the caffe net definition:

gender_net = caffe.Classifier(gender_net_model_file, gender_net_pretrained,
                       mean=mean,
                       channel_swap=(2,1,0),
                       raw_scale=255,
                       image_dims=(256, 256))

It requests to swap the channel which gives BGR order. I think the mean usually is in RGB order so I want to make sure what's the order the mean.binaryblob is given.

The raw_scale=255 is also strange since the input matrix is in 0~1. If I miss anything above, please correct me.

Original Images

Hi Levi,
Thank you for your great works.
I want to download original images set, but in database page there is only cropped faces.
Where can I download them.

Thank you very much.

Optimal image for detection

Hello,

Thanks for all this work!

I have a question: what is the optimal image that should be sent in the neural network? I'm trying to use your network with videos. However, results seems to be very differents according to the image sent for detection.

What I've done:

1 - People detection + face detection
2 - Alignement
3 - We sent the aligned image to the neural network.

--> Do I have to sent only the face aligned? Or a larger cropped part of the image?

Moreover: it seems that the neural network will detect all the time if you send an image with a "black" border

Thanks a lot!

Gender classification based on hair style?

This is not a bug issue.

Just curious about that is it possible to consider the hair style as a factor for gender classification?

Because in real world, most (not 100%) women are with longer hair than men. Seeing one person with hair long below shoulder, pretty much I'll guess his/her gender a higher probability to be a female.

Thanks.

hello, can I use your trained model for age estimating ? for Chinese face..

I'v got money short and have no GPU computer by hand... and I dont want to cost days on trainning the model, and I dont have huge amount of pictures.

It seems not much precise in my test.. the input is the face I cuted from pictures.
it both turn to 0 when I put in a 1year baby and a 70 year old lady.

net_def='../models/c9e99062283c719c03de/deploy_age.prototxt'
net_mod='../models/c9e99062283c719c03de/age_net.caffemodel'
net = caffe.Classifier(net_def,net_mod ,
image_dims=[256,256], mean=None,
input_scale=None, raw_scale=255.0,
channel_swap=[2,1,0])
inputs = [caffe.io.load_image(filename)]
predictions = net.predict(inputs,0)
print predictions.argmax()

Mean shape incompatible with input shape

Hello,

Thank you for your code. When I run the following function, I come across the mean shape error, any ideas? I used the default model and deploy_age file.
age_net = caffe.Classifier(age_net_model_file, age_net_pretrained,
mean=mean,
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(256, 256))

Error information:
I0314 21:59:41.323429 6578 net.cpp:761] Ignoring source layer data
I0314 21:59:41.329099 6578 net.cpp:761] Ignoring source layer loss
Traceback (most recent call last):
File "/home/c/code/eclipsecode/AgeCNN/src/main.py", line 31, in
image_dims=(256, 256))
File "/home/c/software/gpu_caffe/python/caffe/classifier.py", line 34, in init
self.transformer.set_mean(in_, mean)
File "/home/c/software/gpu_caffe/python/caffe/io.py", line 259, in set_mean
raise ValueError('Mean shape incompatible with input shape.')
ValueError: Mean shape incompatible with input shape.

emotion recognition using lbp and mlbp

Hello, i have download your caffemodel used in emotiw2015 challange. I have not found the code to transform an image to lbp or cyclic-lbp feature. Could you uploud these codes to this project?

Problem with recognize the real age

Hi,
Thank you for your time for building this magic.
But, there are leak in many images between the person and result i get on the user.

How can i improve the result?

Training with age from scratch

Hello thank you for the model you provided. I'm currently working on the age model with two classes and I trained adience as well on two classes and got 83.45% training accuracy. Then I'm trying to finetune that one with a dataset of mine and the training loss isn't going down and it stays static for all of 50k iteration. I kept the hyper parameters of the model the same as you have given. Should I try decreasing the bias_filler of conv2?

Age group labels

The labels for the 8 age groups do not cover all the possible values. What happens to a person whose age falls between two labels. Are they mapped to the closest label, so that the division between groups is half way inbetween.

Tensorflow models

This is not a bug issue.

In https://github.com/dpressel/rude-carnie, it seems use a tensorflow model provided from this repo, in his example it's located at AgeGenderDeepLearning/Folds/tf/age_test_fold_is_1/run-20854, but I can't find it anywhere in both repositories.

Are there tensorflow version models I just missed? Or, should I train it in tensorflow myself to get the models?

Really appreciate for sharing this work.

Mean subtraction for each channel

Hi,

I was wondering if you provide the mean for each channel of the images somewhere? I know you provide pixel wise subtraction, but I would like to try out channelwise. I can't seem to find it in the documentation. Sorry if this is a repeat.

Cheers,
August

faces.tar.gz labels

I downloaded this and then tried to find matching gender labels looking at fold_*_data.txt but cannot find any matching .jpg file names. For example I copied 2282.11597935265_29bcdfa4a5_o.jpg from coarse_tilt_aligned_face.2282.11597935265_29bcdfa4a5_o.jpg to search through each of the fold_*_data.txt files but could not find a match. I see the landmark files included in the same folder but no gender. Please tell me which images and files pairs have gender labels. Thank you

Age Classification accuracy

Hello,

First thank you so much for publishing the code and the pretrained models !

I would like to know a little more about the age classification accuracy you mentioned in your paper, is it for the training set or the test set ? Because I tested your model with ffhq dataset https://github.com/NVlabs/ffhq-dataset, with downsampling image to 256x256, swapping to BGR, subtracting your mean image and center cropping to 227x227. But I got a very poor result, far more below the accurary you presented in your paper :(

Problem with Running Code

I know this question has been posted before, but I'm trying to see what will happen if I change the number of filters for each convolutional layer/change the number of convolutional layers/etc.

So I need to figure out how to run the folds, because I think the Inception software doesn't work with deploy.prototxt or any of the prototxt files that contain the filter and convolution information.

I would also like to know how to prototxt files connect to Rude Carnie's Tensorflow code, specifically deploy.prototxt. Where is this file being ran in Rude Carnie's TensorFlow project? I can get guess.py to work, but I can't get train.py to function correctly, which is where I think deploy.prototxt is being used. If I try to run train.py, I just receive a "no directory" error.

FileNotFoundError: [Errno 2] No such file or directory: '/home/autumn/tensor/AgeGenderDeepLearning-master/Folds/train_val_txt_files_per_fold/test_fold_is_0/md.json'

My other question is the same from then on: In https://github.com/dpressel/rude-carnie, it seems use a tensorflow model provided from this repo, in his example it's located at AgeGenderDeepLearning/Folds/tf/age_test_fold_is_1/run-20854, but I can't find it anywhere in both repositories.

Are there tensorflow version models I just missed? Or, should I train it in tensorflow myself to get the models?

Really appreciate for sharing this work.

Assertion `cur_target >= 0 && cur_target < n_classes’ failed

I have added two extra labels (with corresponding images) to the existing image dataset (one for the age and one for the gender class).
mapping = { 0: '0-2 years', 1: '4-6 years', 2: '8-13 years', 3: '15-20 years', 4: '25-32 years', 5: '38-43 years', 6: '48-53 years', 7: '60 years and above', 8: 'none', 9: 'male', 10: 'female', 11:'none' }
Hence, the network's final output layer is modified to
**self.fc3 = nn.Linear(512, 12)** instead of self.fc3 = nn.Linear(512, 10)

However, I am receiving the below error:
RuntimeError: Assertion cur_target >= 0 && cur_target < n_classes' failed. at /Users/distiller/project/conda/conda-bld/pytorch_1556653464916/work/aten/src/THNN/generic/ClassNLLCriterion.c:92`

Was wondering if you could point out any additional changes I need to make to the network?

Gender Classification Confusion Matrix

I was wondering if you have confusion matrix results for the gender (mis) classification? I could not find any in the paper, but it would be very helpful for me to know. Thanks!

Unbalanced folds

Hi,

I know that #24 is a closed issue, but I am still curious about how these folds are set up. My results are as follows:

Fold 0 as test set: 62%
Fold 1 as test set: 49%
Fold 2 as test set: 58%
Fold 3 as test set: 48%
Fold 4 as test set: 56%

My biggest concern is not just the variation in the test sets (especially 1 and 3), but in the accuracy of the validation sets of each fold. In my experiments, each fold gets easily over 80% of accuracy in the validation sets. It feels as if the unseen data from the test sets is wildly different from the validation sets, thus making hard to tune the model.

Do you have any intuition on why this happens?

Thanks,
Raul

issues

hello,
i have an issue with the library 'caffe'. how i can install it?
Capture

High loss, high accuracy

Dear Sir,

I have been trying to reproduce the results and got some issues:
1.) High loss in age classification, >0.54 on average, the accuracy is comparable to your results.
2.) Very high accuracy in gender classification, 0.96 on average. I am not sure what is wrong. I have attached the log file for gender_fold_0 below.

gender_fold_0.txt

Thank you in advanced.

Question Age

Hello,

Thank you for the model you provided. I was wondering if it was possible to know the exact age with your program because in your article it was indicated. ( It was about exact age and 1-off age)

Label of adience database

Hello,

I was looking the proto and txt file for learning, testing and validation. But I see 4 files for gender and age on each 'test_fold_is_x'.
For example, gender_test.txt - gender_train_subset.txt - gender_train.txt - gender_Val.txt
What do these files represents? In gender_train.txt there are labels of 12 000 images about, there are 5 folders, so 12 000 x 5 = 60 000, it is very high because there are about 20 000 image in the adience align dataset. So what does it represent?

FiducialFaceDetector source code

Hi,
is it possible to get FiducialFaceDetector source code? Currently when I execute FiducialFaceDetector.sh i got Segmentation fault (core dumped)

Filtering Adience prior to benchmarking?

First of all, thanks for providing all this! Had a general question that I think I know the answer to, but wanted to make sure of:

For some of the folds, there is some inconsistent/bad data, for example:

fold_0.txt:

113804525@N05 11846455104_455a9c2c76_o.jpg 319 35 m 803 1075 529 529 -90 0 64
113804525@N05 11846455104_455a9c2c76_o.jpg 320 (25, 32) f 1104 1612 504 504 -85 0 38
113804525@N05 11846455104_455a9c2c76_o.jpg 321 3 m 929 634 376 376 -95 0 35

^ These are duplicates, with only one of the age categories being valid. In the folds that are generated in the folder "train_val_txt_files_per_fold", it appears that the correct label for this is "4", which corresponds to (25, 32).

Is it generally acceptable to simply remove all rows where the age is either missing or incorrect? This dataset appears to be used as a benchmark by many other papers, and I want to make sure that I align in what kinds of filtering I do on the test set. Apologies in advance if this has been discussed somewhere else

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.