fix: replace Math.random() mock in vision scanner with real BioScanner TensorFlow inference#690
Open
lofidebugger wants to merge 2 commits into
Open
fix: replace Math.random() mock in vision scanner with real BioScanner TensorFlow inference#690lofidebugger wants to merge 2 commits into
lofidebugger wants to merge 2 commits into
Conversation
…r TensorFlow inference (fixes Shruti070107#689)
…ke REST endpoints (fixes #ISSUE_NUMBER)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The captureAndAnalyze function in src/vision-scanner.js was generating completely fake AI scores using Math.random()
to return a random number between 60 and 95 instead of performing any real analysis. The real TensorFlow.js MobileNet
implementation already existed in src/scanner.js and was exposed globally as window.BioScanner but was never connected to the vision scanner.
On top of that vision-scanner.js was not even included in index.html so the component was not loading in the app at all.
This fix connects the two by replacing the fake mock block with a real call to window.BioScanner.performScan() and adds the missing script tag to index.html. The captureAndAnalyze function is now async and handles edge cases like missing BioScanner, low confidence results, and non-organic waste classification following the same error handling pattern already used in this file.
Since the Trust Protocol and rewards system rely on accurate segregation scores this fix makes the entire platform integrity actually trustworthy.
What Changed
after scanner.js so window.BioScanner is available
captureAndAnalyze in vision-scanner.js
undefined results, low confidence below 30, and
non-organic waste classification
Related Issue
Fixes #689
Type of Change
Validation