As part of a learning exercise, I've trained a couple of machine learning models to detect and recognize a wide variety of fruits. The models are loaded locally in the browser via WebGPU, and all detection is done client side, so no data gets sent outside of the client.
Try it out!
The fruitlens web app
Architecture
I split the problem of recognizing fruits in a scene into 2 smaller separate problems.
Is there a fruit in the scene?
If there is a fruit, what is the fruit?
For the first problem, a detector model reads each frame of the video feed and attempts to find any fruit-like object in the scene. Once found, we then move on to solve the second problem by using a classifier model to attempt to recognize the fruit object.
There are two separate pipelines that train the detector and classifier models. Once trained, the models are then uploaded to a web server.…