svpino / tf_object_detection_cm

Confusion Matrix in Object Detection with TensorFlow
78 stars 36 forks source link

confusion_matrix.py:112: RuntimeWarning: invalid value encountered in double_scalars. #12

Closed techaitr closed 5 years ago

techaitr commented 5 years ago

Hi, I tested it with my new data set and this problem came up.

image

What do you think about this problem ?

techaitr commented 5 years ago

I found my the problem. I chose of false weight graph. Thank you.

jiteshm17 commented 5 years ago

Can you please explain how you resolved this issue?

techaitr commented 5 years ago

I selected the file path as the wrong weight file.

My steps are below.

Step 1: python infer_detections.py --input_tfrecord_paths=C:/tensorflow1/models/research/object_detection/validation.record --output_tfrecord_path=C:/tensorflow1/models/research/object_detection/inference_graph/detections.tfrecord --inference_graph=C:/tensorflow1/models/research/object_detection/inference_graph/frozen_inference_graph.pb

step 2: python confusion_matrix.py --detections_record=C:/tensorflow1/models/research/object_detection/inference_graph/detections.tfrecord --label_map=C:/tensorflow1/models/research/object_detection/training/labelmap.pbtxt I can help if you explain the problem in more detail.

jiteshm17 commented 5 years ago

I just realized I was using the wrong label_map.pbtxt file the whole time. It is working fine now. Thanks anyway. By the way, the script provided has the dimensions of the confusion matrix as (N+1 x N+1) where N is the number of classes. Shouldn't the dimensions be (NxN) instead? Can you please explain the reason for the extra row and column in the confusion matrix

techaitr commented 5 years ago

you can chech below link. it explained in detail. https://www.shiftedup.com/2018/10/10/confusion-matrix-in-object-detection-api-with-tensorflow

jiteshm17 commented 5 years ago

Ok. thanks, I missed the point talking about the final row

jiteshm17 commented 5 years ago

Can anyone please explain how to calculate the number of True positves, False positives, False negatives and True negatives for each class

svpino commented 5 years ago

https://groups.bme.gatech.edu/groups/biml/resources/useful_documents/Test_Statistics.pdf

Aysenur112 commented 3 years ago

Hi, I used the below commands to print the confusion matrix Step 1: python inference/infer_detections.py --input_tfrecord_paths=C:/tensorflow1/models/research/object_detection/test.record --output_tfrecord_path=C:/tensorflow1/models/research/object_detection/inference_graph/detection_tfrecord --inference_graph=C:/tensorflow1/models/research/object_detection/inference_graph/frozen_inference_graph.pb

Step 2: python confusion_matrix.py --detections_record=C:/tensorflow1/models/research/object_detection/inference_graph/detection_tfrecord --label_map=C:/Tensorflow1/models/research/object_detection/training/labelmap.pbtxt --output_path=confusion_matrix.csv

I got the confusion matrix but the rows are columns are showing as zero. Precision and recall are showing as NAN. Could you please help me to solve the issue?

techaitr commented 3 years ago

Merhaba Aysenur,

Öncelikle aynı sorunu yaşamışız fakat yukarıda bahsettiğim gibi sorun yanlış weight graph'dan kaynaklıydı. Benim çözümümde kullandığım path yukarıdaki gibi sende dikkatli bir şekilde bakarsan dosya yoluna sorununu çözebilir.

In English, Hi,

First of all, we experienced the same problem, but as I mentioned above, the problem was caused by the wrong weight graph. The path I use in my solution can solve your problem if you look carefully at the path as above.

Aysenur112 commented 3 years ago

Merhaba, Kullandığınız labelmap.pbtxt dosyası, aşağıdaki gibi sınıf id lerinin yazıldığı dosya değil mi?

item { id: 1 name: 'x' }

item { id: 2 name: 'y' }

item { id: 3 name: 'z' }

techaitr commented 3 years ago

Merhaba,

Muhtemelen öyleydi ama sorununuz dosya yolunda doğru dosyaları kullandığınıza emin olun. Aşağıdaki gibi yazmışsınız. python inference/infer_detections.py --input_tfrecord_paths=C:/tensorflow1/models/research/object_detection/test.record --output_tfrecord_path=C:/tensorflow1/models/research/object_detection/inference_graph/_detectiontfrecord --inference_graph=C:/tensorflow1/models/research/object_detection/inference_graph/frozen_inference_graph.pb

"detection_tf.record" şeklinde olması gerekmez mi? belki de hatanız budur.

Aysenur112 commented 3 years ago

Merhaba, Sorun dosya yolunda değilmiş, dediğiniz gibi yapmama rağmen sorun düzelmedi. Test ve train dosyalarınızı .record formatında dosyalara dönüştürmeden önce test ve train dosyalarınız .csv formatında mıydı yoksa .json formatında mı?

techaitr commented 3 years ago

Merhaba, xml > csv > .record sırasıyla bu şekildeydi.

techaitr commented 3 years ago

mail adresini paylaşırsan döküman gönderebilirim.