Giter VIP home page Giter VIP logo

mtcnn-tensorflow's Introduction

Description

This work is used for reproduce MTCNN,a Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks.

Prerequisites

  1. You need CUDA-compatible GPUs to train the model.
  2. You should first download WIDER Face and Celeba.WIDER Face for face detection and Celeba for landmark detection(This is required by original paper.But I found some labels were wrong in Celeba. So I use this dataset for landmark detection).

Dependencies

  • Tensorflow 1.2.1
  • TF-Slim
  • Python 2.7
  • Ubuntu 16.04
  • Cuda 8.0

Prepare For Training Data

  1. Download Wider Face Training part only from Official Website , unzip to replace WIDER_train and put it into prepare_data folder.
  2. Download landmark training data from here,unzip and put them into prepare_data folder.
  3. Run prepare_data/gen_12net_data.py to generate training data(Face Detection Part) for PNet.
  4. Run gen_landmark_aug_12.py to generate training data(Face Landmark Detection Part) for PNet.
  5. Run gen_imglist_pnet.py to merge two parts of training data.
  6. Run gen_PNet_tfrecords.py to generate tfrecord for PNet.
  7. After training PNet, run gen_hard_example to generate training data(Face Detection Part) for RNet.
  8. Run gen_landmark_aug_24.py to generate training data(Face Landmark Detection Part) for RNet.
  9. Run gen_imglist_rnet.py to merge two parts of training data.
  10. Run gen_RNet_tfrecords.py to generate tfrecords for RNet.(you should run this script four times to generate tfrecords of neg,pos,part and landmark respectively)
  11. After training RNet, run gen_hard_example to generate training data(Face Detection Part) for ONet.
  12. Run gen_landmark_aug_48.py to generate training data(Face Landmark Detection Part) for ONet.
  13. Run gen_imglist_onet.py to merge two parts of training data.
  14. Run gen_ONet_tfrecords.py to generate tfrecords for ONet.(you should run this script four times to generate tfrecords of neg,pos,part and landmark respectively)

Some Details

  • When training PNet,I merge four parts of data(pos,part,landmark,neg) into one tfrecord,since their total number radio is almost 1:1:1:3.But when training RNet and ONet,I generate four tfrecords,since their total number is not balanced.During training,I read 64 samples from pos,part and landmark tfrecord and read 192 samples from neg tfrecord to construct mini-batch.

  • It's important for PNet and RNet to keep high recall radio.When using well-trained PNet to generate training data for RNet,I can get 14w+ pos samples.When using well-trained RNet to generate training data for ONet,I can get 19w+ pos samples.

  • Since MTCNN is a Multi-task Network,we should pay attention to the format of training data.The format is:

    [path to image][cls_label][bbox_label][landmark_label]

    For pos sample,cls_label=1,bbox_label(calculate),landmark_label=[0,0,0,0,0,0,0,0,0,0].

    For part sample,cls_label=-1,bbox_label(calculate),landmark_label=[0,0,0,0,0,0,0,0,0,0].

    For landmark sample,cls_label=-2,bbox_label=[0,0,0,0],landmark_label(calculate).

    For neg sample,cls_label=0,bbox_label=[0,0,0,0],landmark_label=[0,0,0,0,0,0,0,0,0,0].

  • Since the training data for landmark is less.I use transform,random rotate and random flip to conduct data augment(the result of landmark detection is not that good).

Result

result1.png

result2.png

result3.png

reult4.png

result5.png

result6.png

result7.png

result8.png

result9.png

Result on FDDB result10.png

License

MIT LICENSE

References

  1. Kaipeng Zhang, Zhanpeng Zhang, Zhifeng Li, Yu Qiao , " Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks," IEEE Signal Processing Letter
  2. MTCNN-MXNET
  3. MTCNN-CAFFE
  4. deep-landmark

mtcnn-tensorflow's People

Contributors

aittsmd avatar sumsuddin avatar vslm698 avatar zm931116 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  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

mtcnn-tensorflow's Issues

Training Face Landmark Detection

Hi @AITTSMD , I'm very new to python and I get this problem while running gen_landmark_aug_12.py.
File "gen_landmark_aug_12.py", line 180, in
imgs,landmarks = GenerateData(train_txt, OUTPUT,net,argument=True)
File "gen_landmark_aug_12.py", line 67, in GenerateData
assert(img is not None)
AssertionError
May I know what causes this problem and how to solve it?
Thank you.

关于模型测试是的问题

你好,我在对于训练好的模型测试时发现,正脸时5个关键点都很好地拟合对应位置,但是将图片倾斜(相当于正脸旋转了一定的角度)一定的角度测试时,5个关键点的位置就会偏差很大,所以我想问出现这种情况可能会是哪些问题引起的呢?在图像预处理的时候是否需要做正脸旋转处理呢?
谢谢!

class TestLoader:

def get_batch(self):
imdb = self.imdb[self.cur]
im = cv2.imread(imdb)
self.data = im

您好,最近参考您的代码,请问TensorFlow处理的时候(使用tf.image.decode_jpeg),颜色顺序是RGB, 但是opencv是BGR, 是不是应该用cv2.cvtColor(im, cv2.COLOR_BGR2RGB)转换一下

gen_imglist_rnet.py

Dear AITTSMD, i've tried to strictly follow your instruction from readme file.
After gen_imglist_rnet.py of step 9 your instruction, I receive
File "gen_imglist_rnet.py", line 18, in
with open(os.path.join(data_dir, '%s/pos_%s.txt' % (size, size)), 'r') as f:
IOError: [Errno 2] No such file or directory: './24/pos_24.txt'

looks smthing is missing. Could you please share a hint?

Retrain

I want to train MTCNN using my own dataset. can you please give me some hint to do that?, for example:

  1. Format of the dataset, like naming the folder and image.
  2. Train the network to produce the model

[Disscussion]How to imporove pnet recall

Thanks very much for the work!
I am trying something interesting, MTCNN for cat heads!
Unfortunately, I could only have 10,000 labeled cat head example, which is much less than human face datasets. I divide the data set to 80% training and 20% testing/validation.
For pnet, the recall on validation set is around 91%, with the threshold 0.9. I change the number in gen_12net_data.py for more pos/part/neg samples, but is not helping.
Question, how to improve pnet recall.
for my problem. cat heads share much larger variance in both shape and texture. I am thinking about a larger deeper net work.
any discussion is welcome!

gen_hard_example.py中有些地方没看明白

您好,非常感谢您开源了mtcnn的训练代码!我一直比较好奇mtcnn的训练数据是如何构造的,所以主要看了您的prepare_data代码。在看gen_hard_example.py时,有3个疑问,请求解答:
1、这份代码的目的是为RNet或者ONet准备数据,所以,对应的应该是输入数据到PNet或PNet-RNet,得到预测的bbox,再进行IoU判断,最终得到pos,neg,part这三种标记。请问是这样理解的吗?
2、函数t_net中的数据源filename = './wider_face_train_bbx_gt.txt',是如何得到的?
3、函数t_net为什么需要ONet?如代码第142,148行,而且并没有从from train_models.mtcnn_model import O_Net。

关于landmark的一些询问!

您好,看到您回答问题都是用的中文,所以我就用中文了。我最近也是在用tensorflow来复现mtcnn,基于的是之前的一个mxnet的上进行的修改,然后我的问题主要就是在landmark的问题上。我所用的landmark的数据就是从celebA中得到的,我所用的方式就是按照celebA给出的bbox信息,直接裁剪出bbox的图片,然后相对于gt的bbox得到landmark的几个坐标相对于gt的bbox的偏移量再除以size,然后直接把这个作为train的landmark的信息,和pos,neg,part的信息放进去进行train,但是loss还是不够满意,我看了下您的landmark的设置,觉得比我的要复杂很多,可否简单给我讲讲您这部分的思路呢?非常感谢

Did you do pyramid in testing?

Hi,
Thanks for sharing the code.
Did you do resize the image to different scales to build an image pyramid just like paper did?
If yes, which .py is it?

Many thanks!

Dimension Error In MTCNN_Model

When i am training in p-net Layer using the script train_Pnet.py.I got an error in the script of Mtcnn_model.py at
line no: 144
cls_prob = tf.squeeze(conv4_1,[1,2],name='cls_prob')

The error is ValueError: Can not squeeze dim[1], expected a dimension of 1, got 19 for 'cls_prob' (op: 'Squeeze') with input shapes: [384,19,19,2].
Can anyone explain what this error meant for.

fail to make tfrecord

I just go through preparing data step until step 6:Run gen_PNet_tfrecords.py to generate tfrecord for PNet.
a Segmentation fault (core dumped) error after some long logs of running.

Converting image 1437679/1437687('---', '12/positive/67987.jpg')
Converting image 1437680/1437687('---', '12/train_PNet_landmark_aug/97899.jpg')
Converting image 1437681/1437687('---', '12/positive/36229.jpg')
Converting image 1437682/1437687('---', '12/positive/173181.jpg')
Converting image 1437683/1437687('---', '12/train_PNet_landmark_aug/172922.jpg')
Converting image 1437684/1437687('---', '12/positive/15968.jpg')
Converting image 1437685/1437687('---', '12/positive/71556.jpg')
Converting image 1437686/1437687('---', '12/negative/709222.jpg')
Converting image 1437687/1437687('---', '12/negative/18498.jpg')
Segmentation fault (core dumped)

I check that image, looks ok.

gen_hard_example.py的询问

首先感谢您的代码,我在实现的时候有些地方没看明白,还望您能指教下:

  1. 您的代码中,有两处需要调用这个函数,在步骤7中,您给出的是python gen_hard_example.py --test_mode pnet,但是在t_net函数中,已经设定了test_mode 为PNet,有点不明白
    2.在后面一次产生训练样本时,是否使用命令 python gen_hard_example.py --test_mode rnet? t_net函数需要改变吗?
    再次感谢您

step 7

你好,我在根据您开源的代码学习mtcnn.有个问题想请教一下:
step7时,要运行gen_hard_example.py生成generate training data for RNet.
第143为什么会在Detector中restore RNet模型(我是重新训练,并没有data这个文件.)

Landmarks detection

Hi @AITTSMD,

As you stated there was an issue with using CelebA dataset for training, due to some corrupted labels.
I see now that there is an issue with only "101283.jpg" image that has the following bounding box annotation: "101283.jpg 320 828 0 0" which is invalid.

All the rest of the records seems valid.

Regards,
Ilya

制作landmark数据的时候,在计算loss的时候,能否把这些图片也当成正例来计算loss?

在使用gen_landmark_12_aug.py生成landmark数据时,把label设成了-2。

f.write(join(dstdir, "%d.jpg" % (image_id)) + " -2 " + " ".join(landmarks) + "\n")

能不能把-2的也在难例计算loss的时候当作正例来计算?

因为在做ohem的时候,函数def cls_ohem(cls_prob, label):中,

...
label_filter_invalid = tf.where(tf.less(label, 0), zeros, label)
num_cls_prob = tf.size(cls_prob)
# 把cls_prob_reshape展开成batch*2 X 1
cls_prob_reshape = tf.reshape(cls_prob, [num_cls_prob, -1])
label_int = tf.cast(label_filter_invalid, tf.int32)
num_row = tf.to_int32(cls_prob.get_shape()[0])
row = tf.range(num_row) * 2
indices_ = row + label_int
label_prob = tf.squeeze(tf.gather(cls_prob_reshape, indices_))
loss = -tf.log(label_prob + 1e-10)

把landmark的所有脸,也都变成为负例来计算loss。

而在选择难例的时候,会把之前作为负例计算的loss,全部筛掉。

    zeros = tf.zeros_like(label_prob, dtype=tf.float32)
    ones = tf.ones_like(label_prob, dtype=tf.float32)
    valid_inds = tf.where(label < zeros, zeros, ones)
    num_valid = tf.reduce_sum(valid_inds)
    keep_num = tf.cast(num_valid * num_keep_radio, dtype=tf.int32)
    # set 0 to invalid sample
    loss = loss * valid_inds
    loss, _ = tf.nn.top_k(loss, k=keep_num)

为什么在挖掘难例的时候,只挖正例, 而不对负例进行挖掘?

关于max pooling filter size的问题

hi,在mtcnn_model.py中的模型定义中,发现max pooling层的filter size不是根据原paper定义的。例如O-net在代码中为:

net = slim.conv2d(inputs, num_outputs=32, kernel_size=[3,3], stride=1, scope="conv1")
        
net = slim.max_pool2d(net, kernel_size=[2,2],stride=2,scope="pool1")
       
 net = slim.conv2d(net,num_outputs=64,kernel_size=[3,3],stride=1,scope="conv2")
        
net = slim.max_pool2d(net,kernel_size=[2,2],stride=2,scope="pool2")
        
net = slim.conv2d(net,num_outputs=64,kernel_size=[3,3],stride=1,scope="conv3")
        
net = slim.max_pool2d(net,kernel_size=[2,2],stride=2,scope="pool3")
       
 net = slim.conv2d(net,num_outputs=128,kernel_size=[2,2],stride=1,scope="conv4")

在paper中第一个max pooling filter size为33,第二个为33,第三个为2*2

snipaste_20171019_151754

请问这样的设定是有什么特别的原因吗。
谢谢!

Getting issue while processing with "widerface" dataset using "Tensorflow"

/home/sysadmin/anaconda2/envs/tensorflow/bin/python /home/sysadmin/loukya/LC/Tensorflow-master/train_models/train_PNet.py
['/home/sysadmin/loukya/LC/Tensorflow-master/train_models', '/home/sysadmin/loukya/LC', '/home/sysadmin/loukya/LC/Tensorflow-master', '/home/sysadmin/loukya/LC/Tensorflow-master/data', '/home/sysadmin/loukya/LC/Tensorflow-master/Detection', '/home/sysadmin/loukya/LC/Tensorflow-master/logs', '/home/sysadmin/loukya/LC/Tensorflow-master/prepare_data', '/home/sysadmin/loukya/LC/Tensorflow-master/prepare_data/WIDER_train', '/home/sysadmin/loukya/LC/Tensorflow-master/prepare_data/WIDER_train/images', '/home/sysadmin/loukya/LC/Tensorflow-master/result', '/home/sysadmin/loukya/LC/Tensorflow-master/test', '/home/sysadmin/loukya/LC/Tensorflow-master/train_models', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python27.zip', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/plat-linux2', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/lib-tk', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/lib-old', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/lib-dynload', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/site-packages', '/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg', '/home/sysadmin/loukya/LC/Tensorflow-master/prepare_data']
/home/sysadmin/loukya/LC_output/imglists/train_PNet_landmark.txt
('Total datasets is: ', 1250000)
/home/sysadmin/loukya/LC_output/12
(64, 48, 48, 3)
(64, 48, 48, 3)
(192, 48, 48, 3)
(64, 48, 48, 3)
(384, 48, 48, 3)
(384,)
(384, 4)
(384, 48, 48, 3)
(384, 46, 46, 10)
(384, 23, 23, 10)
(384, 21, 21, 16)
(384, 19, 19, 32)
(384, 1, 1, 2)
(384, 1, 1, 4)
(384, 1, 1, 10)
WARNING:tensorflow:From /home/sysadmin/loukya/LC/Tensorflow-master/train_models/mtcnn_model.py:154: get_regularization_losses (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30.
Instructions for updating:
Use tf.losses.get_regularization_losses instead.
2017-10-05 17:07:23.236709: 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.
2017-10-05 17:07:23.236755: 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.
2017-10-05 17:07:23.236761: 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.
2017-10-05 17:07:27.217108: W tensorflow/core/kernels/queue_base.cc:302] _0_batch/fifo_queue: Skipping cancelled dequeue attempt with queue not closed
2017-10-05 17:07:27.217148: W tensorflow/core/kernels/queue_base.cc:302] _7_batch_3/fifo_queue: Skipping cancelled dequeue attempt with queue not closed
2017-10-05 17:07:27.217162: W tensorflow/core/kernels/queue_base.cc:302] _2_batch_1/fifo_queue: Skipping cancelled dequeue attempt with queue not closed
carry out!!!
Traceback (most recent call last):
File "/home/sysadmin/loukya/LC/Tensorflow-master/train_models/train_PNet.py", line 31, in
train_PNet(base_dir, prefix, end_epoch, display, lr)
File "/home/sysadmin/loukya/LC/Tensorflow-master/train_models/train_PNet.py", line 17, in train_PNet
train(net_factory,prefix, end_epoch, base_dir, display=display, base_lr=lr)
File "/home/sysadmin/loukya/LC/Tensorflow-master/train_models/train.py", line 210, in train
coord.join(threads)
File "/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/training/queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1063, in _single_operation_run
target_list_as_strings, status, None)
File "/home/sysadmin/anaconda2/envs/tensorflow/lib/python2.7/contextlib.py", line 24, in exit
self.gen.next()
File "/home/sysadmin/anaconda2/envs/tensorflow/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.NotFoundError: /home/sysadmin/loukya/LC_output/12/neg_landmark.tfrecord_shuffle
[[Node: ReaderReadV2_2 = ReaderReadV2[_device="/job:localhost/replica:0/task:0/cpu:0"](TFRecordReaderV2_2, input_producer_2)]]

Process finished with exit code 1

how to improve the accuracy of a model and confidence score

Hi,
I am doing face detection using tensorflow. successfully I got the face detection and found the number of detected faces. In the detection module some of the faces have not detected.
How can I resolve that and How do I want to improve the model accuracy or confidence score.

I am thinking, if I can change the hyper parameters i.e learning rate to improve the model accuracy
or again I need to train from starting onwards by changing the hyper parameters.
Can I train this model on another dataset. is this going to increase the model accuracy ?

thanks in advance

Validation Code

After completion of training how can I validate model can you suggest me how to validate model?
If any code related to validation can you please help me out.
thanks in advance

why the ContROC score so low than DiscROC

After finish training onet, I test trained model on FDDB with your code RunOnFDDBLandmark.py, I change the trained epoch from [18, 14, 16] to [30, 22, 22], keep threshold [0.6, 0.15, 0.05] same, then I got DiscROC
discroc
ContROC
controc

My question:

The DiscROC is similar with yours, but the ContRoc seems not good? so is there something wrong in the code, what can I do to improve this cure?

The threshold setting are really confused me, in one_image_test.py you set them to [0.9, 0.6, 0.7], but in RunOnFDDBLandmark.py you set them to [0.6, 0.15, 0.005], again in gen_hard_example.py you set them [0.4, 0.05, 0.7], so how to setting these threshold in my application, are there some principle to follow.

Thanks for sharing this code, it helps me a lot!!!

MTCNN 模型需要多大显存?

陈少,你好,我在跑程序的时候出现cuda_error_out_of_memory错误
017-10-13 00:39:02.833148: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Found device 0 with properties: name: Tesla M40 major: 5 minor: 2 memoryClockRate(GHz): 1.112 pciBusID: 0000:82:00.0 totalMemory: 11.93GiB freeMemory: 11.82GiB 2017-10-13 00:39:02.833193: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1055] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla M40, pci bus id: 0000:82:00.0, compute capability: 5.2) 2017-10-13 00:39:02.863038: E tensorflow/stream_executor/cuda/cuda_driver.cc:936] failed to allocate 11.93G (12808486912 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
请问,你跑MTCNN算法的GPU是哪个型号? @AITTSMD

训练其他关键点结果不准的问题

您好,我想训练上下嘴唇的点,也进行标注了,但是发现两个点总是融合为一个点,我想请问下,是数据的问题还是模型的问题呢?麻烦您了

Get error: fc1/alphas not found in checkpoint when i run python one_image_test.py

when i test the model by issue follow command ,i get the error:

python one_image_test.py

error message as follow:

(virtualenv) ➜  test git:(master) ✗ python one_image_test.py
(1, ?, ?, 3)
(1, ?, ?, 10)
(1, ?, ?, 10)
(1, ?, ?, 16)
(1, ?, ?, 32)
(1, ?, ?, 2)
(1, ?, ?, 4)
(1, ?, ?, 10)
2017-11-23 14:25:45.140042: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
../data/MTCNN_model/PNet_landmark/PNet-18
restore models' param
(256, 24, 24, 3)
(256, 22, 22, 28)
(256, 11, 11, 28)
(256, 9, 9, 48)
(256, 4, 4, 48)
(256, 3, 3, 64)
(256, 576)
(256, 128)
(256, 2)
(256, 4)
(256, 10)
../data/MTCNN_model/RNet_landmark/RNet-14
restore models' param
2017-11-23 14:25:46.070231: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key fc1/alphas not found in checkpoint
Traceback (most recent call last):
  File "one_image_test.py", line 32, in <module>
    RNet = Detector(R_Net, 24, batch_size[1], model_path[1])
  File "../Detection/detector.py", line 25, in __init__
    saver.restore(self.sess, model_path)                        
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1666, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 889, in run
    run_metadata_ptr)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1120, in _run
    feed_dict_tensor, options, run_metadata)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run
    options, run_metadata)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key fc1/alphas not found in checkpoint
	 [[Node: save/RestoreV2_13 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_13/tensor_names, save/RestoreV2_13/shape_and_slices)]]

Caused by op u'save/RestoreV2_13', defined at:
  File "one_image_test.py", line 32, in <module>
    RNet = Detector(R_Net, 24, batch_size[1], model_path[1])
  File "../Detection/detector.py", line 17, in __init__
    saver = tf.train.Saver()
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1218, in __init__
    self.build()
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1227, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1263, in _build
    build_save=build_save, build_restore=build_restore)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 751, in _build_internal
    restore_sequentially, reshape)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 427, in _AddRestoreOps
    tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 267, in restore_op
    [spec.tensor.dtype])[0])
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 1021, in restore_v2
    shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
    op_def=op_def)
  File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

NotFoundError (see above for traceback): Key fc1/alphas not found in checkpoint
	 [[Node: save/RestoreV2_13 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_13/tensor_names, save/RestoreV2_13/shape_and_slices)]]

(virtualenv) ➜  test git:(master) ✗ 

And my environment is macOS Sierra 10.12.6:
Python 2.7.13
tensorflow (1.4.0)
tensorflow-tensorboard (0.4.0rc3)
virtualenv (15.1.0)
numpy (1.13.3)
pip (9.0.1)
easydict (1.7)

PNet的准确率疑问

@AITTSMD 感谢你的代码
我在训练PNet的时候得到的cls的准确率是0.94~0.96之间,cls的loss值在0.22左右徘徊,roi和landmark的还是不错的,对于PNet着重于cls训练的神经层来说,这样的结果是否有些偏低?

Pyramid scaling

Hi @AITTSMD , can you explain why you use the scale like this first "current_scale = float(net_size) / self.min_face_size"? and then scale by 0.79. Thanks in advance.

关于增加人脸关键点训练遇到的问题

你好,我在增加人脸关键点(原先5个,现在增加到64个)数据来进行模型训练,原先5个关键点时landmark_loss的曲线会衰减收敛,但是64个关键点时landmark_loss的曲线只会上下浮动不衰减。想请问这可能是由于什么情况引起?谢谢!!!

How to freeze three models?

hi , after I trained MTCNN, I get three fileds with different checkpoint and pbtxt. now i wanna to freezen three models. but when i use freeze.graph.py, it always shows me that output not in graph. can you help to deal with it? thanks a lot.

MTCNN Frozen Model

Hey guys,

I was wondering if there is a way to freeze the trained MTCNN model from this implementation into a protobuf file

I've seen Facenet and also other examples requiring only one .pb frozen file that contain PNet,Rnet and also Onet into the same file. Is there a way to freeze my trained networks into one file being able to access the networks like this?
('pnet/conv4-2/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0':img}
('rnet/conv5-2/conv5-2:0', 'rnet/prob1:0'), feed_dict={'rnet/input:0':img}
('onet/conv6-2/conv6-2:0', 'onet/conv6-3/conv6-3:0', 'onet/prob1:0')

Thanks a lot!

The stocked model gives worse result?

It seems the results are not as good as it is publicized.

(打扰了,请问例子给出的结果用的是提供的模型吗?)

No face detected in this image:

fb_indian_1204_100

Some obvious faces are not detected in this image (also sensitive with occlusion/hat, rotation, blur, over-

lala_screenshot_26 12 2017_16
exposure):

lala_screenshot_26 12 2017

lala_screenshot_26 12 2017_15

lala_screenshot_26 12 2017_13

lala_screenshot_26 12 2017_5

Plus, if provided more epochs of training, does the problem resolve?

slice indices must be integers

Hi,

I was trying to generate Pnet training data as the step 3. I have already checked that I putted WIDER_train folder in prepare_data dir, but the training data cannot be generated because of this error (slice indices must be integers or None or have an __index__ method)

landmark问题

您好,我想问一下在训练过程中有没有对嘴角两个点做特别的处理?

gen_hard_example出错:Key fc1/alphas not found in checkpoint

@AITTSMD 您好,感谢您的开源工作。
想通过您的工作熟悉一下MTCNN的训练过程,我已经按照您的指引以默认配置完成了PNet的训练,接下来是按照【After training PNet, run gen_hard_example to generate training data(Face Detection Part) for RNet.】的指引,运行gen_hard_example脚本生成RNet的训练数据,但是总是出错,在加载预训练模型RNet-14的model时出错:
../data/MTCNN_model/RNet_landmark/RNet-14
restore models' param
2017-11-01 16:41:20.483995: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key fc1/alphas not found in checkpoint
2017-11-01 16:41:20.484165: W tensorflow/core/framework/op_kernel.cc:1152] Not found: Key fc1/alphas not found in checkpoint
请教该如何解决?

train RNet report error : empty tensor

Hi @AITTSMD
Thank you for your great work!
I want to train MTCNN according to your introduction. repeat for times. but when I train RNet model, I met a issue,error shows an empty tensor size is zero, so I print the data, showing bbox_batch_array is all zero, I don't know the reason.
could you help me giving me some advice? thank you!

error as below:

image_batch_array (384, 24, 24, 3)
label_batch_array (384,)
bbox_batch_array (384, 4)
landmark_batch_array (384, 10)
label_batch_array -2.0
bbox_batch_array [[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]]
landmark_batch_array [ 0.22222221 0.27160493 0.75925922 0.33950618 0.58641976 0.67901236
0.17283952 0.86419755 0.67901236 0.91358024]
W tensorflow/core/framework/op_kernel.cc:993] Invalid argument: Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero
[[Node: gradients/TopKV2_grad/Reshape = Reshape[T=DT_INT32, Tshape=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](TopKV2/_351, gradients/TopKV2_grad/stack)]]

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.