Skip to content

fix: increase edge inference confidence threshold to reject non-fish images#114

Merged
jpdevhub merged 1 commit into
jpdevhub:mainfrom
sks-007:fix/issue-99-offline-inference-threshold
Jun 22, 2026
Merged

fix: increase edge inference confidence threshold to reject non-fish images#114
jpdevhub merged 1 commit into
jpdevhub:mainfrom
sks-007:fix/issue-99-offline-inference-threshold

Conversation

@sks-007

@sks-007 sks-007 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Resolves #99

Problem Statement

When running the application in offline mode, taking a picture of a non-fish object (like a human face or generic object) often resulted in the app blindly accepting the image and returning a bogus "Fresh" score, rather than explicitly rejecting it.

Root Cause

The NOT_A_FISH_THRESHOLD in src/fusionInference.js was configured to 0.36. Because the Stream A MobileNet model has 3 classes, pure random chance yields a baseline probability of 0.33. This meant the threshold was so low that almost any out-of-distribution image's maximum class probability would pass the check, successfully bypassing the guardrail.

Solution Implemented

  • Increased NOT_A_FISH_THRESHOLD from 0.36 to 0.55.
  • Added an explanatory comment above the constant.

This requires the model to be significantly more confident than random chance before accepting an image as a valid fish, effectively filtering out generic objects and faces without the payload overhead of downloading a secondary object-detection model.

Testing Performed

  • Verified offline edge inference with various fish images successfully passes the new threshold.
  • Verified offline edge inference with non-fish objects (faces, coffee mugs) correctly falls below the 55% threshold and triggers the NOT_A_FISH error state.

Potential Impacts

Very blurry or poorly lit legitimate fish images might occasionally fall below the 55% confidence threshold, requiring the user to rescan (which is the intended safe fallback behavior).

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@sks-007 is attempting to deploy a commit to the karan3431's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fresh-scan-ai Ready Ready Preview, Comment Jun 22, 2026 8:45am

@jpdevhub jpdevhub left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing

@jpdevhub jpdevhub merged commit 3f1987d into jpdevhub:main Jun 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Offline Edge Inference flags non-fish objects as "Fresh"

2 participants