Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCD Evaluation Metrics RuntimeWarning: invalid value encountered in scalar divide #86

Open
JoyLinWQ opened this issue Dec 17, 2024 · 1 comment

Comments

@JoyLinWQ
Copy link

JoyLinWQ commented Dec 17, 2024

Hi @ChenHongruixuan , I'm encountering the following error due to zeros in the confusion matrix when running on my own images.

CM: [[29900574. 1556706.]
[ 0. 0.]]

/home/jupyter/MambaCD/changedetection/utils_func/metrics.py:25: RuntimeWarning: invalid value encountered in scalar divide
  Rec = self.confusion_matrix[1, 1] / (self.confusion_matrix[1, 0] + self.confusion_matrix[1, 1])
Rec:  nan
Pre:  0.0
F1:  nan
Racall rate is nan, Precision rate is 0.0, OA is 0.9505136489868165, F1 score is nan, IoU is 0.0, Kappa coefficient is 0.0
Inference stage is done!

When running the LEVIR-CD+ dataset, i can get the following:

CM:  [[1.26982791e+08 3.97602000e+05]
 [3.46063000e+05 6.49127200e+06]]
Rec:  0.9493862740380572
Pre:  0.942283455902953
F1:  0.9458215301836073
Racall rate is 0.9493862740380572, Precision rate is 0.942283455902953, OA is 0.9944592639803886, F1 score is 0.9458215301836073, IoU is 0.8972119591366172, Kappa coefficient is 0.9429019112092241
Inference stage is done!

What could be the problem with my own dataset?

I've ensured that i have:

  • T1 images
  • T2 images
  • GT (white 255 polygons with black 0 background) - T1 building masks in greyscale, without alpha channel
  • All images are in 1024x1024
  • binary change map range is 0-1, and after binary_change_map[binary_change_map==1] = 255 it is 0-255.
  • decent output prediction masks.

Any help is appreciated. Thanks.

@ChenHongruixuan
Copy link
Owner

Hi @JoyLinWQ ,

It seems that all pixels are predicted to have a value of 0. I think you need to check the following: first, check whether our trained weights have been loaded successfully; second, the format of your dataset needs to be consistent with LEIVIR-CD+ (e.g., the value of the changed pixel needs to be 255, not 1); finally, can you show us some examples of your dataset? This way we can better help analyze the cause.

Best,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants