GithubHelp home page GithubHelp logo

boyuanjiang / age-gender-estimate-tf Goto Github PK

View Code? Open in Web Editor NEW
533.0 22.0 160.0 70.58 MB

Face age and gender estimate using TensorFlow

License: MIT License

Python 62.07% Jupyter Notebook 37.93%
tensorflow-examples age-gender-cnn

age-gender-estimate-tf's Introduction

Age and gender estimation based on Convolutional Neural Network and TensorFlow


UPDATE: There are some compatibility issues under python3 reported by others, recommend using python2 or you should adjust some codes manually

This is a TensorFlow implement of face age and gender estimation which first using dlib to detect and align faces in the picture and then using a deep CNN to estimate age and gender.As you can see below,this project can estimate more than one face in a picture at one time.

demo1 demo2

Dependencies

This project has following dependencies and tested under CentOS7 with Python2.7.14

  • tensorflow==1.4
  • dlib==19.7.99
  • cv2
  • matplotlib==2.1.0
  • imutils==0.4.3
  • numpy==1.13.3
  • pandas==0.20.3

Usage

Make tfrecords

In order to train your own models,you should first download imdb or wiki dataset,and then extract it under data path,after that,images path should look like

/path/to/project/data/imdb_crop/00/somepictures
/path/to/project/data/imdb_crop/01/somepictures
....
/path/to/project/data/imdb_crop/99/somepictures

Then you can run

python convert_to_records_multiCPU.py --imdb --nworks 8

to convert images to tfrecords.--imdb means using imdb dataset,--nworks 8 means using 8 cpu cores to convert the dataset parallelly.Because we will first detect and align faces in the pictures,which is a time consuming step,so we recommend to use as many cores as possible.Intel E5-2667 v4 and with 32 cores need approximately 50 minutes.

Train model

Once you have converted images to tfrecords,you should have the following path:

/path/to/project/data/train/train-000.tfrecords
......
/path/to/project/data/test/test-000.tfrecords
......

At present,our deep CNN uses FaceNet architecture,which based on inception-resnet-v1 to extract features.To speed up training,we use the pretrained model's weight from this project and have converted the weight to adapt our model,you can download this converted pretrained facenet weight checkpoint from here or here.Extract it to path models.

/path/to/project/models/checkpoint
/path/to/project/models/model.ckpt-0.data-00000-of-00001
/path/to/project/models/model.ckpt-0.index
/path/to/project/models/model.ckpt-0.meta

NOTE: This step is optional,you can also train your model from scratch. To start training,run

python train.py --lr 1e-3 --weight_decay 1e-5 --epoch 6 --batch_size 128 --keep_prob 0.8 --cuda

NOTE: Using the flag --cuda will train the model with GPU.

Using tensorboard to visualize learning

tensorboard --logdir=./train_log

train log

Test model

You can test all your trained models on testset through

python test.py --images "./data/test" --model_path "./models" --batch_size 128 --choose_best --cuda

Flag --cuda means using GPU when testing.--choose_best means testing all trained models and return the best one.If you just want to test the latest saved model,without this flag.

python test.py --images "./data/test" --model_path "./models" --batch_size 128 --cuda

One picture demo

If you just want to test the model on your own picture,run

python eval.py --I "./demo/demo.jpg" --M "./models/" --font_scale 1 --thickness 1

Flag --I tells where your picture is.If the text label too small or too large on the picture,you can use a different --font_scale 1 and --thickness 1 to adjust the text size and thickness. We also provide a pretrained model,you can download from here or here and extract it to models path.

Picture from web cam

web cam

First download the pretrained model from here or here and extract to models path. In order to get pictures from web cam, you may need to uninstall your cv2 and install it from source if have problems when running the below command:

python demo.py 

TODO

  • First version of project
  • Code review and add some commits
  • Add a readme doc
  • Add a demo using pictures from web cam

References and Acknowledgments

This project is a part of my class project of Machine Learning course at Zhejiang University,following papers and codes are referred:

  1. Rothe R, Timofte R, Van Gool L. Dex: Deep expectation of apparent age from a single image[C]//Proceedings of the IEEE International Conference on Computer Vision Workshops. 2015: 10-15.
  2. Rothe R, Timofte R, Van Gool L. Deep expectation of real and apparent age from a single image without facial landmarks[J]. International Journal of Computer Vision, 2016: 1-14.
  3. IMDB-WIKI – 500k+ face images with age and gender labels
  4. yu4u/age-gender-estimation
  5. davidsandberg/facenet
  6. Face Alignment with OpenCV and Python

age-gender-estimate-tf's People

Contributors

boyuanjiang 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

age-gender-estimate-tf's Issues

测试一张图片大约要多久

使用python eval.py --I "./img/1_4.jpg" --M "./models/" --font_scale 1 --thickness 1我测试一张大约要20秒,感觉好慢,有什么可以调节的地方让他快一点吗,谢谢

waiting during converting to tensoflow records.

sudo python convert_to_records_multiCPU.py --imdb --nworks 8
[sudo] password for aries:
Using imdb dataset
Writing ./data/train/train-000.tfrecords
Writing ./data/train/train-001.tfrecords
Writing ./data/train/train-002.tfrecords
Writing ./data/train/train-003.tfrecords
Writing ./data/train/train-004.tfrecords
Writing ./data/train/train-005.tfrecords
Writing ./data/train/train-006.tfrecords
Writing ./data/train/train-007.tfrecords

I tried python convert_to_records_multiCPU.py --imdb --nworks 32,
but it cannot finish this process too.

What can I do?

Error while running convert_to_records.py

Hey there.
I love your program, it's very, very nice.
But i am getting this error, maybe you can help me?

Askes-MBP:DareToAGE aske$ python convert_to_records_multiCPU.py --imdb --nworks 2 Traceback (most recent call last): File "convert_to_records_multiCPU.py", line 28, in <module> import cv2 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2/__init__.py", line 4, in <module> from .cv2 import * ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2/cv2.so, 2): Symbol not found: _clock_gettime Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib (which was built for Mac OS X 10.12) Expected in: /usr/lib/libSystem.B.dylib in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2/.dylibs/libavutil.55.78.100.dylib Askes-MBP:DareToAGE aske$

Kind regards

执行train.py训练报错

执行命令就是作者给的命令 但是报了下面的错误
tensorflow.python.framework.errors_impl.InvalidArgumentError: Name: , Feature: file_name (data type: string) is required but could not be found.
报错位置:
Traceback (most recent call last):
File "train.py", line 145, in
log_dir=args.log_path, start_lr=args.learning_rate, wd=args.weight_decay, kp=args.keep_prob)
File "train.py", line 125, in run_training
coord.join(threads)
一直找不到什么原因 ,请问又遇到这种情况的吗,还望帮解答一下

error in train.py

tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 12288 values, but the requested shape has 76800
[[Node: input/Reshape = Reshape[T=DT_UINT8, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"](input/DecodeRaw/_2099, input/Reshape/shape)]]
[[Node: input/per_image_standardization/_2101 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_32_input/per_image_standardization", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

problem in convert_to_records_multiCPU.py

执行结果
Using imdb dataset
Writing ./data/train/train-000.tfrecords
Writing ./data/train/train-001.tfrecords
Writing ./data/train/train-002.tfrecords
Writing ./data/train/train-003.tfrecords
Writing ./data/train/train-004.tfrecords
Writing ./data/train/train-005.tfrecords
Writing ./data/train/train-006.tfrecords
Writing ./data/test/test-000.tfrecords
Writing ./data/test/test-001.tfrecords
Writing ./data/train/train-007.tfrecords
Running 32.910 sec All done!
您好,我刚刚接触人脸识别这个领域,执行demo 时,执行时间明显不合理,请问能解答下吗?谢谢了

unable to run test.py

Hello,
Recently I am trying to run your code to detect the age and gender. However, when I use python test.py --images "./data/test" --model_path "./models" --batch_size 128 --choose_best --cuda to test the images, there are something wrong.
Following are the wrong messages:

Traceback (most recent call last):
File "test.py", line 108, in
args.batch_size)
File "test.py", line 89, in main
batch_size)
File "test.py", line 77, in choose_best_model
ckpt.all_model_checkpoint_paths[idx], )
File "test.py", line 63, in test_once
coord.join(threads)
File "/home/happyforever/.local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/home/happyforever/.local/lib/python2.7/site-packages/tensorflow/python/training/queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "/home/happyforever/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1231, in _single_operation_run
target_list_as_strings, status, None)
File "/home/happyforever/.local/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.DataLossError: corrupted record at 0
[[Node: input/ReaderReadV2 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/device:CPU:0"](input/TFRecordReaderV2, input/input_producer)]]
[[Node: input/ParseSingleExample/ParseExample/ParseExample/_995 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_18_input/ParseSingleExample/ParseExample/ParseExample", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:GPU:0"]]

And while I test your model with your python eval.py --I "./demo/demo.jpg" --M "./models/" --font_scale 1 --thickness 1 without changing your demo.jpg, there are some errors as well.

Traceback (most recent call last):
File "eval.py", line 97, in
aligned_image, image, rect_nums, XY = load_image(args.image_path, args.shape_detector)
File "eval.py", line 45, in load_image
predictor = dlib.shape_predictor(shape_predictor)
RuntimeError: Error deserializing object of type int64
while deserializing a floating point number.
while deserializing a dlib::matrix
while deserializing object of type std::vector
while deserializing object of type std::vector
while deserializing object of type std::vector

Could you tell me what's wrong? Thank you!

pretrained model

Hi,
Good work on this repo!
I wanted to know if the project already has pre-trained model/weights for the age detection?because when I run demo.py it gives the first age prediction correct but continues to give the same prediction even with different faces?
when I checked the code it seems that we need to pass the model path which is by default "model" folder however that folder doesn't contain any models! I was wondering if the problem I'm having is because of this? or is it another problem?

Hope you can help me with that.

Thanks,

How can I train on the mutil gpu ?

Hello, Thanks for your sharing. It's convinient for me your detailed tutorial.
I am curious about the GPU capacity required for default parameter training.

1.My per GPU is small, so I need train on mutil gpu.
2.If you are free, would you minding shaing some suggestions for me to train ?
3.I've tried the command (but it seems not work well.):

CUDA_VISIBLE_DEVICES="0,1,2,3" python train.py --lr 1e-3 --weight_decay 1e-5 --epoch 6 --batch_size 16 --keep_prob 0.8 --cuda

This command only use the first gpu. It's unscientific and strange

Problem when using test.py

Hello,

I've tried to execute test.py with the pre-trained model you provide in the description.
I am using the following command:

python test.py --images "./data/test" --model_path "./models" --batch_size 128 --cuda

having in ./data/test the tfrecords generated with Wiki dataset and convert_to_records_multiCPU.py, and
the pretrained model in models (checkpoint, model.ckpt-14001.data-00000-of-00001 and so on).

However, I am receiving this output:

2018-04-20 13:12:24.750659: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 !!!TESTING DONE!!! Traceback (most recent call last): File "test.py", line 116, in <module> ckpt.model_checkpoint_path) File "test.py", line 65, in test_once return prob_age_val, real_age, prob_gender_val, real_gender, image_val, np.mean(mean_error_age), np.mean( UnboundLocalError: local variable 'prob_age_val' referenced before assignment

What's going wrong?

Thank you so much!

20 year old baby

Hi,

Just managed to this project running and my first tries was very disappointing. Tried 3 photos of a child in the age of 1-3 years. All predictions landed on 15-20 years old. The most obvious one is the one where she is 1 year old, and predicted to be 20.

20_year_old_baby

Could there be something in the way I installed the depencies or something else that is making the predictions so wrong ? I dont get any errors.

Dont try this

this program is noob and had a lot of problems and bugs. Just find another... Thankyou. Please subscribe me XP

Licence

Can you please add the license file for this project.

Race, Emotion, etc. Identification

Hello,

First of all, I'm really interested in your project and I think it's pretty good so congratulations. This is not exactly an issue, I just wanna ask you if it could be possible to provide more estimated information such as emotion estimation, race estimation and these kind of typical attibutes on an easy way. I mean, I suppose that I'd have to use a train/test dataset with these new attributes and make some changes on the model and your code but would it be achievable? I'm a begginner at ML so I apologize if my question does not make so much sense.

Thank you!

about train question

just like total_loss = gender_loss + age_loss + L2_loss
use AdamOptimizer optimizer

but the gender accuracy is up to 0.90+, and age accuracy is only about 0.50+

how to solve this question?

Error in Train.py

Hi, very thanks for your project and you effort !!
Do you have any idea, why train.py doesn't work. ? I have tensorflow 1.4.0.

restore and continue training!
2018-04-09 12:23:47.425063: W D:\dump\tf\tf1.4-1\tensorflow\core\framework\op_kernel.cc:1192] Invalid argument: Name: , Feature: file_name (data type: string) is required but could not be found.

2018-04-09 12:23:49.061344: W D:\dump\tf\tf1.4-1\tensorflow\core\framework\op_kernel.cc:1192] Invalid argument: Name: , Feature: file_name (data type: string) is required but could not be found.
Model saved in file: ./models\model.ckpt-0

Traceback (most recent call last):
File "train.py", line 145, in
log_dir=args.log_path, start_lr=args.learning_rate, wd=args.weight_decay, kp=args.keep_prob)
File "train.py", line 125, in run_training
coord.join(threads)
File "C:\Program Files\programovani\Python35\lib\site-packages\tensorflow\python\training\coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "C:\Program Files\programovani\Python35\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Program Files\programovani\Python35\lib\site-packages\tensorflow\python\training\queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "C:\Program Files\programovani\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1231, in _single_operation_run
target_list_as_strings, status, None)
File "C:\Program Files\programovani\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Name: , Feature: file_name (data type: string) is required but could not be found.
[[Node: input/ParseSingleExample/ParseExample/ParseExample = ParseExample[Ndense=4, Nsparse=0, Tdense=[DT_INT64, DT_STRING, DT_INT64, DT_STRING], dense_shapes=[[], [], [], []], sparse_types=[], _device="/job:localhost/replica:0/task:0/device:CPU:0"](input/ParseSingleExample/ExpandDims, input/ParseSingleExample/ParseExample/ParseExample/names, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_0, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_1, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_2, input/ParseSingleExample/ParseExample/ParseExample/dense_keys_3, input/ParseSingleExample/ParseExample/Const, input/ParseSingleExample/ParseExample/ParseExample/names, input/ParseSingleExample/ParseExample/Const, input/ParseSingleExample/ParseExample/ParseExample/names)]]

Predict the age on an 'average' ages in real time

The output varies too quickly to be interpreted well at times. How would be to take a 100 frames and print the average value of the predictions.
say 100 frames, and run the prediction on that average image.
How i do it?

ValueError: Cannot feed value of shape

It's appreciate for you to share the code. But there is a little wired problem.
When I use some pictures to test, it will raise the following error.
The picture's info is as listed:
default

I have tested the other picture in the same size(960 * 1280), it will be ok.
Could you help me?
Thanks

  File "/home/jimmy/anaconda3/envs/facetest2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1096, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 1280, 960, 3) for Tensor u'input_image:0', which has shape '(?, 160, 160, 3)'

训练数据集

您好!非常感谢您的分享!
但我有个疑问,文中分享的模型:
you can download this converted pretrained facenet weight checkpoint from here or here.Extract it to path models.
/path/to/project/models/checkpoint
/path/to/project/models/model.ckpt-0.data-00000-of-00001
/path/to/project/models/model.ckpt-0.index
/path/to/project/models/model.ckpt-0.meta

是在那些数据集上进行的训练呢? Imdb? wiki ? 还是lmdb+wiki

年龄值和对应的概率值相乘再求和是什么意思

年龄值和对应的概率值相乘再求和是什么意思
age_ = tf.cast(tf.constant([i for i in range(0, 101)]), tf.float32)
age = tf.reduce_sum(tf.multiply(tf.nn.softmax(age_logits), age_), axis=1)
为什么不能用argmax求最大可能性的年龄

Accuracy

Is it possible to extract from somewhere in the output the accuracy about the gender and the age classification ?
For example, "female" with 0.98 of accuracy.
Same for the age.

By the way, this project is awesome.
Thanks for sharing it.

模型固化问题

能在train.py训练模型的同时,保存为ckpt格式之外,再保存为一份.pb格式的么?
我在网上找了一段保存为pb的代码
from tensorflow.python.framework import graph_util

##################模型封装
output_graph_def = graph_util.convert_variables_to_constants(sess, sess.graph_def,
output_node_names=["output"])
# 形参output_node_names用于指定输出的节点名称(不是指的要输出的节点的名称)
pb_file_path = " my_net/save_net.pb"
with tf.gfile.FastGFile(pb_file_path, mode='wb') as f:
f.write(output_graph_def.SerializeToString())

##################模型封装
但是因为是初学者没有找到output_node_names(用于指定输出的节点名称)在你的代码中具体变量名是哪个,能指点一下么?谢谢。

About model transfer

Here you said "we use the pretrained model's weight from this project and have converted the weight to adapt our model", could you share the code how to convert the weight to adapt the model? Thank you very much.

Issue running convert_to_records.py (and multiCPU).

Hello, this is an amazing code, thank you for allowing us to view it. I'm attempting to convert the IMDB data set into records and I get the following error:

/usr/local/lib/python2.7/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "convert_to_records.py", line 188, in
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "convert_to_records.py", line 151, in main
data_sets = get_meta('./data/imdb_crop/imdb.mat','imdb')
File "convert_to_records.py", line 123, in get_meta
meta = loadmat(mat_path)
File "/usr/local/lib/python2.7/dist-packages/scipy/io/matlab/mio.py", line 141, in loadmat
MR, file_opened = mat_reader_factory(file_name, appendmat, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/scipy/io/matlab/mio.py", line 64, in mat_reader_factory
byte_stream, file_opened = _open_file(file_name, appendmat)
TypeError: 'NoneType' object is not iterable

Additionally, if I wanted to run the convert_to_records.py on my GPU, would I use the syntax:

python convert_to_records.py --imdb --cuda

Thank you for your time!

How can we convert .ckpt model to tflite model for use on mobile device?

I have successfully trained one age and gender detection model and i got .ckpt model file and its working and predicting correctly with satisfied accuracy now i want to convert this .ckpt model into .tflite tensorflow lite model for run this model on mobile device.

Please help me how can i convert .ckpt model to tflite model for use on mobile device?

Error in train.py

Hi, very thanks for your project and you effort !!
Do you have any idea, why train.py doesn't work. ? I have tensorflow 1.4.0. Thank you very much!

pci bus id: 0000:00:0a.0, compute capability: 6.0)
2018-07-16 10:10:26.461140: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:1) -> (device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:0b.0, compute capability: 6.0)
2018-07-16 10:10:26.461146: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:2) -> (device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:0c.0, compute capability: 6.0)
2018-07-16 10:10:26.461151: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:3) -> (device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:0d.0, compute capability: 6.0)
restore and continue training!
244.201 sec
520.449 sec
Model saved in file: s3://bucket-7601/models/model.ckpt-1001
523.704 sec
Model saved in file: s3://bucket-7601/models/model.ckpt-1152
Traceback (most recent call last):
File "train/train_tf.py", line 147, in
log_dir=args.log_path, start_lr=args.learning_rate, wd=args.weight_decay, kp=args.keep_prob)
File "train/train_tf.py", line 125, in run_training
coord.join(threads)
File "/usr/local/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/usr/local/anaconda2/lib/python2.7/site-packages/tensorflow/python/training/queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "/usr/local/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1231, in _single_operation_run
target_list_as_strings, status, None)
File "/usr/local/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.DataLossError: truncated record at 2904972900
[[Node: input/ReaderReadV2 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/device:CPU:0"](input/TFRecordReaderV2, input/input_producer)]]

These things are always too hard to install

Huge amount of dependencies (OpenCV, Boost, TensorFlow), No setup.py, no requirements.txt, and then, specifically, dependencies in the readme which can't be found?? (cv2 and dlib==19.7.99). I'm sorry, there were too many scars, I will not try to hunt down random dependencies ever again.

Making my own image recognition now anyway, but this program would have been nice to try out IF there was an easy way to install it.

Cheers everyone

problem about test.py

when i run
python test.py --images "/home/wuchen/download/Age-Gender-Estimate-TF/demo/" --model_path "/home/wuchen/download/Age-Gender-Estimate-TF/models/" --batch_size 128 --cuda

[[Node: input/shuffle_batch = QueueDequeueUpToV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
2018-01-26 22:02:09.668516: W tensorflow/core/framework/op_kernel.cc:1192] Out of range: RandomShuffleQueue '_2_input/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 128, current size 0)
[[Node: input/shuffle_batch = QueueDequeueUpToV2[component_types=[DT_FLOAT, DT_INT64, DT_INT64, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input/shuffle_batch/random_shuffle_queue, input/shuffle_batch/n)]]
!!!TESTING DONE!!!
Traceback (most recent call last):
File "test.py", line 116, in
ckpt.model_checkpoint_path)
File "test.py", line 63, in test_once
coord.join(threads)
File "/home/wuchen/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/home/wuchen/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/training/queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "/home/wuchen/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1235, in _single_operation_run
target_list_as_strings, status, None)
File "/home/wuchen/anaconda3/envs/py2/lib/python2.7/contextlib.py", line 24, in exit
self.gen.next()
File "/home/wuchen/anaconda3/envs/py2/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.DataLossError: corrupted record at 0
[[Node: input/ReaderReadV2 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/cpu:0"](input/TFRecordReaderV2, input/input_producer)]]
[[Node: input/ParseSingleExample/ParseExample/ParseExample/_1001 = _Recvclient_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_47_input/ParseSingleExample/ParseExample/ParseExample", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/gpu:0"]]

thanks, if u know why, please tell me

utils.py

Hello,
Your project is really interesting! I would like to know what if I want to do the data augmentation like random flip, what can I do? Can I just use "image = tf.image.random_flip_left_right(image)"? Will the labels change? Thanks!

def read_and_decode(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
# Defaults are not specified since both keys are required.
features={
'image_raw': tf.FixedLenFeature([], tf.string),
'age': tf.FixedLenFeature([], tf.int64),
'gender': tf.FixedLenFeature([], tf.int64),
'file_name': tf.FixedLenFeature([], tf.string)
})
above are the same as yours**
image = tf.image.decode_jpeg(features['image_raw'], channels=3)
image = tf.image.resize_images(image, [64, 64])
image = tf.image.random_flip_left_right(image)
following are the same as yours in utils.py**
image = tf.decode_raw(features['image_raw'], tf.uint8)
image.set_shape([160 * 160 * 3])
image = tf.reshape(image, [160, 160, 3])

what's the config about train_log.jpg ?

Hello, I finally can run train.py.
I find train_log.jpg in the folder train_log/ and am curious about what's config does train_log.jpg use ?
Because the epoch is 6 and step is 61000 in train.py demo. There is 601000 steps in train_log.

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.