# Rice Quality Assessor
I took on a coding challenge and built a fully offline Android app that runs rice quality assessment using a ConvNeXt-Small model that I finetuned — entirely on-device. Built for the Zindi AfricaRice Quality Assessment Challenge, where the core requirement was a working field tool for farmers, rice traders etc in areas without reliable internet.
**Final standing: 22nd out of 50 teams/individuals — public score 0.755 · competition leaderboard**
---
## What it does
Take a picture of rice grains on a blue background, press capture, and ~32 seconds later get:
- Total grain count with how many are broken/long/medium, Dimensions of grains like avg length, width, L/W ratio, Defects like how many grains are chalky, black, red, yellow, or green and CIELAB colour profile (L\*, a\*, b\*), so the farmers and traders can do an informed descision and quickly assess what tier the rice belong to. This is an early quick assessment tool not something you solely rely on.
---
## Finetuning the model
The model is a ConvNeXt-Small backbone with 9 independent MultiScale CSR density heads (one per grain category) and a regression head for morphological measurements provided to us by Zindi along with the documentation and link to data source so we could finetune it for mobile.
The original model was trained on a 6×8 tile grid (the image was split into 48 chunks and then assessed) the model won 3rd place in previous competition and had near 1-2 MAE. The challenge was it took more than 5 minutes on my A52 (a midrange phone with 8gigs of ram) but we cannot use it this way as the app was supposed to run on low end devices too 3-4 gigs of ram so we cannot cram this 220MB model, the images it scans into ram. As app will stop responding again and again.
First I quantized it to int-8 (which was a challenge in itself as much math functions in float32 couldn't be quantized for lack of support on mobile tf and onnx library), this version also took 3 minutes way over the …