PUTvision / qgis-plugin-deepness

Deepness is a remote sensing plugin that enables deep learning inference in QGIS
https://www.buymeacoffee.com/deepness
Apache License 2.0
106 stars 24 forks source link

Clipping [0,1] as postprocessing step #149

Open mg515 opened 8 months ago

mg515 commented 8 months ago

Hey. I was hoping someone can explain the reasoning behind [0,1] clipping as a postprocessing step in order to obtain "the mask with the probability of the presence of the class in the image". It seems to me that uncontrolled clipping the model outputs can be rather dangerous, since the logits that come out of the model are unconstrained. In case there is a softmax layer applied already within onnx graph, clipping does nothing either way.

Context: I am trying out different probability thresholds from within the UI and can not observe much of a difference between setting 0.01 and 0.99 (I have a binary segmentation task). What is the recommended way to prepare the model to enable this?

https://github.com/PUTvision/qgis-plugin-deepness/blob/eb994e79b0b5c83b0c746f34e32a5ba9cf62e461/src/deepness/processing/models/segmentor.py#L40

przemyslaw-aszkowski commented 8 months ago

Hi The assumption for the segmentation model is it should return the probability in the range 0 - 1. I think you may be right, the clip is not needed. Regarding the issue you described - if you have only one output class, then this class will be always picked as the most probably, even while having 0 probability, as we have argmax at the end. To achieve what you described, you should add another output class to your model ("background" class at output number 0). Cheers Przemek