MTCNN-Tensorflow icon indicating copy to clipboard operation
MTCNN-Tensorflow copied to clipboard

Train MTCNN with a fixed size input

Open hoavt-54 opened this issue 7 years ago • 9 comments

Hi there,

Thanks for sharing the code. I'm trying to train MTCNN with a fixed size input, say 1000x1000. Could you please suggest where should I modify to achieve that? I tried to read the code and the placeholder input shape of Pnet is (batch_size, 12,12,3). I thought it should be (batch_size, None, None, 3)?

Thanks

hoavt-54 avatar Nov 16 '18 04:11 hoavt-54

Hi, i have met the problem when i train P-net, can i ask you for some help?

hqq1990 avatar Nov 28 '18 06:11 hqq1990

I think you misunderstood the model itself, the trainning process of MTCNN requires you to randomly crop the original image and resize it to 12x12. During the predicting process you can use abitrary size as long as the image size within a batch is same. if you still insist trainning MTCNN in other size rather than 12x12 you don't have to change any part of the model it self, because P-Net is a fully convolutional net.

zm931116 avatar Nov 30 '18 07:11 zm931116

您好,我在训练PNET时遇到问题,可以请教下吗?我并没有改变维数,不知道为什么会出现这个错误 [image: 屏幕快照 2018-11-28 下午3.35.40.png]

zm931116 [email protected] 于2018年11月30日周五 下午4:02写道:

I think you misunderstood the model itself, the trainning process of MTCNN requires you to randomly crop the original image and resize it to 12x12. During the predicting process you can use abitrary size as long as the image size within a batch is same. if you still insist trainning MTCNN in other size rather than 12x12 you don't have to change any part of the model it self, because P-Net is a fully convolutional net.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AITTSMD/MTCNN-Tensorflow/issues/217#issuecomment-443111376, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJ2TP9h10JNiQMkVSZnrXnCe8VF2YMQks5u0Nf3gaJpZM4YlPBD .

hqq1990 avatar Nov 30 '18 09:11 hqq1990

额,你这个错误的图片我好像看不到

zm931116 avatar Dec 04 '18 06:12 zm931116

啊?这样啊 那方便留一个邮箱吗?或者加个QQ 微信 方便吗?

zm931116 [email protected] 于2018年12月4日周二 下午3:22写道:

额,你这个错误的图片我好像看不到

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AITTSMD/MTCNN-Tensorflow/issues/217#issuecomment-443985686, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJ2TB7R7CA99qY2tLniqOEac6SsGxbzks5u1hS8gaJpZM4YlPBD .

hqq1990 avatar Dec 04 '18 06:12 hqq1990

我把图片作为附件重发给您了,您看下你不能看到

zm931116 [email protected] 于2018年12月4日周二 下午3:22写道:

额,你这个错误的图片我好像看不到

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AITTSMD/MTCNN-Tensorflow/issues/217#issuecomment-443985686, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJ2TB7R7CA99qY2tLniqOEac6SsGxbzks5u1hS8gaJpZM4YlPBD .

hqq1990 avatar Dec 04 '18 06:12 hqq1990

你加我微信吧,zm1993931116

zm931116 avatar Dec 04 '18 06:12 zm931116

你好,我训练完模型之后,将meta文件,固话成pb文件时,做c++调用,pnet模型由于固定了输入图片的batchsize和大小,导致不能输入任意其他大小的图片,我尝试将输入改为(None, None, None, 3) ,但是出现计算分类损失时需要这个batchsize大小,所以我在定义的时候这个batchsize就不能为空,但我必须这样定义(None, None, None, 3),我的后续pb模型才能输入一张任意大小的图片.

LiYangDoYourself avatar Mar 04 '19 09:03 LiYangDoYourself

@LiYangDoYourself 你好,我最近也在搞这个MTCNN的C++实现。我是将Pnet固化为input shape为[1, None,None,3] Pb文件,想用tensorflow再读入测试验证正确性,但是在执行模型的predict时总是报如下错,请问你遇到过吗?(你有没有做pb模型的测试验证呢)

从错误信息上看,应该是提示我输入的placeholder的shape应该为[1, ?, ? ,3],但是我输入就是满足这个shape的?

You must feed a value for placeholder tensor 'input_1' with dtype float and shape [1,?,?,3] [[node input_1 (defined at F:\tensorflow_model_learn\mtcnn_learn\MTCNN-Tensorflow-master\Detection\fcn_detector.py:70) = Placeholderdtype=DT_FLOAT, shape=[1,?,?,3], _device="/job:localhost/replica:0/task:0/device:CPU:0"]] Caused by op 'input_1', defined at: File "c:\Users\ADMIN.vscode\extensions\ms-python.python-2019.2.5558\pythonFiles\ptvsd_launcher.py", line 45, in main(ptvsdArgs) File "c:\Users\ADMIN.vscode\extensions\ms-python.python-2019.2.5558\pythonFiles\lib\python\ptvsd_main_.py", line 357, in main run() File "c:\Users\ADMIN.vscode\extensions\ms-python.python-2019.2.5558\pythonFiles\lib\python\ptvsd_main_.py", line 257, in run_file runpy.run_path(target, run_name='main') File "D:\Python35\lib\runpy.py", line 254, in run_path pkg_name=pkg_name, script_name=fname) File "D:\Python35\lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "D:\Python35\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "f:\tensorflow_model_learn\mtcnn_learn\MTCNN-Tensorflow-master\test\camera_test_pb_model.py", line 24, in PNet = FcnDetectorPB(P_Net, model_path_pnet) File "F:\tensorflow_model_learn\mtcnn_learn\MTCNN-Tensorflow-master\Detection\fcn_detector.py", line 70, in init _ = tf.import_graph_def(output_graph_def, name="") File "D:\Python35\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func return func(*args, **kwargs) File "D:\Python35\lib\site-packages\tensorflow\python\framework\importer.py", line 442, in import_graph_def _ProcessNewOps(graph) File "D:\Python35\lib\site-packages\tensorflow\python\framework\importer.py", line 234, in _ProcessNewOps for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access File "D:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3440, in _add_new_tf_operations for c_op in c_api_util.new_tf_operations(self) File "D:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3440, in for c_op in c_api_util.new_tf_operations(self) File "D:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3299, in _create_op_from_tf_operation ret = Operation(c_op, self) File "D:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1770, in init self._traceback = tf_stack.extract_stack() InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input_1' with dtype float and shape [1,?,?,3] [[node input_1 (defined at F:\tensorflow_model_learn\mtcnn_learn\MTCNN-Tensorflow-master\Detection\fcn_detector.py:70) = Placeholderdtype=DT_FLOAT, shape=[1,?,?,3], _device="/job:localhost/replica:0/task:0/device:CPU:0"]] File "F:\tensorflow_model_learn\mtcnn_learn\mtcnn-tensorflow-master\detection\fcn_detector.py", line 82, in predict cls_prob, bbox_pred = self.sess.run([self.cls_prob, self.bbox_pred],feed_dict={self.image_op: databatch}) File "F:\tensorflow_model_learn\mtcnn_learn\mtcnn-tensorflow-master\detection\mtcnndetector.py", line 221, in detect_pnet cls_cls_map, reg = self.pnet_detector.predict(im_resized) File "F:\tensorflow_model_learn\mtcnn_learn\mtcnn-tensorflow-master\detection\mtcnndetector.py", line 371, in detect boxes, boxes_c, _ = self.detect_pnet(img) File "F:\tensorflow_model_learn\mtcnn_learn\mtcnn-tensorflow-master\test\camera_test_pb_model.py", line 44, in boxes_c,landmarks = mtcnn_detector.detect(image)

zjd1988 avatar Mar 24 '19 02:03 zjd1988