简体   繁体   English

Tensorflow 对象检测在 Python 和 C++(OpenCV) 之间有不同的结果

[英]Tensorflow object detection has different results between Python and C++(OpenCV)

i trained a model by using TF OF API.我使用 TF OF API 训练了一个模型。 Then, when i tested the model with Python and C++(OpenCV) codes linked below, i am getting different results.然后,当我使用下面链接的 Python 和 C++(OpenCV)代码测试模型时,我得到了不同的结果。 The results getting from Python is better than C++(OpenCV) results.从 Python 获得的结果比 C++(OpenCV) 的结果要好。 What does cause this difference?造成这种差异的原因是什么?

Python Test Code: https://github.com/vijaydwivedi75/Custom-Mask-RCNN_TF/blob/master/mask_rcnn_eval.ipynb Python 测试代码: https : //github.com/vijaydwivedi75/Custom-Mask-RCNN_TF/blob/master/mask_rcnn_eval.ipynb

C++(OpenCV) Test Code: https://github.com/spmallick/learnopencv/blob/master/Mask-RCNN/mask_rcnn.cpp C++(OpenCV) 测试代码: https : //github.com/spmallick/learnopencv/blob/master/Mask-RCNN/mask_rcnn.cpp

Trained Model and Sample Images: https://drive.google.com/open?id=18RaJfk6-DXfZJWEL61YdOAztoJxdUbua训练模型和示例图像: https : //drive.google.com/open?id=18RaJfk6-DXfZJWEL61YdOAztoJxdUbua

I am getting .pb model from checkpoints by using this code: https://github.com/tensorflow/models/blob/master/research/object_detection/export_inference_graph.py我使用以下代码从检查点获取 .pb 模型: https : //github.com/tensorflow/models/blob/master/research/object_detection/export_inference_graph.py

I am getting .pbtxt file by using this code: https://github.com/opencv/opencv/blob/master/samples/dnn/tf_text_graph_mask_rcnn.py我使用以下代码获取 .pbtxt 文件: https : //github.com/opencv/opencv/blob/master/samples/dnn/tf_text_graph_mask_rcnn.py

OpenCV Version: 4.2.0, Tensorflow Version using for train: 1.12.0 OpenCV 版本:4.2.0,用于训练的 Tensorflow 版本:1.12.0

Thanks for your help.谢谢你的帮助。

It was totally about mismatch between train images sizes and keep aspect ratio resizer min/max dimensions.这完全是关于训练图像大小不匹配并保持纵横比调整器最小/最大尺寸。 In Python, model resizes input image.在 Python 中,模型调整输入图像的大小。 But, in OpenCV, there is no any resizing operation.但是,在 OpenCV 中,没有任何调整大小的操作。 Because of these, i was getting different results.由于这些,我得到了不同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM