Skip to content

feat: custom TensorFlow.js model for waste contamination detection (#673)#681

Open
knoxiboy wants to merge 1 commit into
Shruti070107:mainfrom
knoxiboy:fix/issue-673-tfjs-scanner
Open

feat: custom TensorFlow.js model for waste contamination detection (#673)#681
knoxiboy wants to merge 1 commit into
Shruti070107:mainfrom
knoxiboy:fix/issue-673-tfjs-scanner

Conversation

@knoxiboy

@knoxiboy knoxiboy commented Jun 13, 2026

Copy link
Copy Markdown

Resolves #673

Description

This PR integrates a custom TensorFlow.js classification model inside the AI Bio Scanner to detect bio-waste contamination (plastics, metal, glass) and output a granular organic purity score, automatically flagging contaminated batches.

What changed

  • Added loadCustomModel and runCustomModel inside src/scanner.js using tf.sequential to define a lightweight CNN layer structure.
  • Modified classifyResult to accept and process probabilities from the custom TF.js model.
  • Established a threshold (90% organic purity) below which batches are automatically flagged as contaminated.
  • Updated src/vision-scanner.js to utilize the custom TF.js model instead of simulated/mock values, maintaining alignment.
  • Exposed loadCustomModel in BioScanner public API.

Why

Standard MobileNet can classify object labels but cannot quantify contamination percentages or detect if non-biodegradable items are mixed within the organic material, which is critical for anaerobic digestion safety.

How to test

  1. Run npm run test to verify structure health.
  2. Load index.html in browser.
  3. Open the AI Bio Scanner, upload a waste image, and verify that the organic content meter displays the granular percentages and flags batches containing high plastic/metal/glass contamination.

Checklist

  • Tested changes locally
  • No lint/syntax errors introduced
  • Matches all issue criteria

Files Affected

  • src/scanner.js
  • src/vision-scanner.js

@knoxiboy

Copy link
Copy Markdown
Author

@Shruti070107 Please review this pr and merge it

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

Successfully merging this pull request may close these issues.

[Task] TensorFlow.js Custom Model for Waste Contamination Detection

1 participant