computational-cell-analytics / micro-sam

Segment Anything for Microscopy
https://computational-cell-analytics.github.io/micro-sam/
MIT License
311 stars 35 forks source link

Create proper error messages for errors in the annotator #572

Closed constantinpape closed 2 months ago

constantinpape commented 2 months ago

While reading the FAQ I noticed the following point:

We are currently aware of the following erros that cause these messages:

  • While using Automatic Segmentation from the finetuned Segment Anything models, the model does not segment any objects. This often happens with the finetuned models, which need lower values for the pred_iou_thresh and the stability_score_thresh. You can change these in the GUI (under Settings in the Automatic Segmentation widget console for AMG-based segmentation). The best approach is the following: lower these thresholds to smaller values (e.g. 0.5 for both). This segments the objects you are interested in, however it also segments unwanted objects. Then choose higher values for the thresholds until the unwanted objects disappear (rerunning this step with different values will be fast after you run the segmentation the first time with lower values).
  • While using interactive annotations, this could happen if the prompts are placed outside the image, the object is segmented using a negative point prompt, or the projection along multidimensional inputs places a projected prompt along the consecutive slices outside the image (etc.). The best approach here is: to clear the annotations and place fresh annotations to segment the object with an updated prompt-placement heuristic.

We should avoid these messages and instead open a pop up window that informs the user about the issue.

@anwai98 can you check for the two points above if they still raise the errors? If yes I will look into opening the window with a proper error message instead.

anwai98 commented 2 months ago

Re:

While using Automatic Segmentation from the finetuned Segment Anything models, the model does not segment any objects. This often happens with the finetuned models, which need lower values for the pred_iou_thresh and the stability_score_thresh. You can change these in the GUI (under Settings in the Automatic Segmentation widget console for AMG-based segmentation). The best approach is the following: lower these thresholds to smaller values (e.g. 0.5 for both). This segments the objects you are interested in, however it also segments unwanted objects. Then choose higher values for the thresholds until the unwanted objects disappear (rerunning this step with different values will be fast after you run the segmentation the first time with lower values).

The current version of our tool does not throw an error anymore. (i.e. in case the threshold values are too high to not segment any objects, it silently just does not show any segmented objects). I think it would be good to wrap the comment above stating something like: "if the Automatic Segmentation feature does not segment any objects, a) for AMG: reduce the X, Y and Z parameters, and b) for AIS: adjust the A, B and C parameters.

I'll follow up on the interactive segmentation.

anwai98 commented 2 months ago

Re:

While using interactive annotations, this could happen if the prompts are placed outside the image, the object is segmented using a negative point prompt, or the projection along multidimensional inputs places a projected prompt along the consecutive slices outside the image (etc.). The best approach here is: to clear the annotations and place fresh annotations to segment the object with an updated prompt-placement heuristic.

I spotted this while I was making the tracking video, one of the daughter cells was almost going out of the frame, and probably the projected prompt was out of the image bounds and throwing some errors, thi s doesn't seem to be the case with 1.0.0 (or probably is random). I also tested placing prompts outside the image in the 2d annotator, doesn't seem to throw any errors anymore.

The mention for the interactive segmentation can go away. Thanks for spotting!

constantinpape commented 2 months ago

The current version of our tool does not throw an error anymore. (i.e. in case the threshold values are too high to not segment any objects, it silently just does not show any segmented objects). I think it would be good to wrap the comment above stating something like: "if the Automatic Segmentation feature does not segment any objects, a) for AMG: reduce the X, Y and Z parameters, and b) for AIS: adjust the A, B and C parameters.

I fixed this in #574 and we now open a window to warn about this.

I spotted this while I was making the tracking video, one of the daughter cells was almost going out of the frame, and probably the projected prompt was out of the image bounds and throwing some errors, thi s doesn't seem to be the case with 1.0.0 (or probably is random). I also tested placing prompts outside the image in the 2d annotator, doesn't seem to throw any errors anymore.

Yes, I think this is fixed now. I iwill update the FAQ accordingly and ask users to open an issue when they encounter it.