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

Selfie Segmentation confidence threshold #807

Open
arianaa30 opened this issue Apr 15, 2024 · 0 comments
Open

Selfie Segmentation confidence threshold #807

arianaa30 opened this issue Apr 15, 2024 · 0 comments
Assignees

Comments

@arianaa30
Copy link

I'm experimenting with the com.google.mlkit:segmentation-selfie:16.0.0-beta5 and the selfie segmentation sample code. Idk why sometimes 0.9 threshold below works and sometimes in different rooms I have to change it to 0.2. Apparently it is very prone to environment and lighting conditions.

Can you make it more stable and prone to lighting conditions in the future versions?

  private int[] maskColorsFromByteBuffer(ByteBuffer byteBuffer) {
    @ColorInt int[] colors = new int[maskWidth * maskHeight];
    for (int i = 0; i < maskWidth * maskHeight; i++) {
      float backgroundLikelihood = 1 - byteBuffer.getFloat();
      if (backgroundLikelihood > 0.9) {
        colors[i] = Color.argb(128, 255, 0, 255);
      } else if (backgroundLikelihood > 0.2) {
        // Linear interpolation to make sure when backgroundLikelihood is 0.2, the alpha is 0 and
        // when backgroundLikelihood is 0.9, the alpha is 128.
        // +0.5 to round the float value to the nearest int.
        int alpha = (int) (182.9 * backgroundLikelihood - 36.6 + 0.5);
        colors[i] = Color.argb(alpha, 255, 0, 255);
      }
    }
    return colors;
  }
@arianaa30 arianaa30 changed the title [Bug report] Title for the bug Selfie Segmentation confidence threshold Apr 15, 2024
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

3 participants
@ai-plays @arianaa30 and others