Back to Today I Write
Today I Learned·5 min read

Why DenseNet169 Won My Waste Classification Benchmark — And How TFLite Made It Practical

Notes from comparing four CNN architectures for waste image classification and deploying the winner onto Android with TensorFlow Lite.

#Machine Learning#Android#TensorFlow Lite#CNN

For my undergraduate thesis at UPN "Veteran" Jawa Timur, I benchmarked four Convolutional Neural Network (CNN) architectures — including DenseNet169, ResNet50, and MobileNetV3 — to classify everyday waste categories from camera photos and run inference directly inside a Kotlin Android app.

The Trade-off Between Accuracy and Edge Latency

Most tutorials tell you to default straight to MobileNet for mobile vision tasks. In practice, waste imagery is visually messy: crumpled plastics, reflective metal cans, wet paper, and inconsistent lighting.

Because DenseNet169 connects each layer to every subsequent layer via feature reuse, it preserved fine-grained texture cues remarkably well across cluttered backgrounds and outperformed the lighter baselines in classification accuracy.

Bridging Research to Android

A great confusion matrix inside a Jupyter Notebook means very little if a user waits three seconds per frame on a mid-range phone. Converting the trained model to TensorFlow Lite taught me three practical lessons:

  • Preprocessing parity is everything. A single mismatch in RGB channel normalization ([0, 1] vs [-1, 1]) silently destroys on-device accuracy even when the model loads without error.
  • Post-training quantization dramatically trims APK weight with negligible accuracy drop when validated against a held-out real-world photo set.
  • UX confidence thresholds matter. Showing "Uncertain — try closer lighting" beats confidently misclassifying a glass bottle as plastic.
kotlin
// Keep inference off the main thread and normalize input consistently
val tensorImage = TensorImage(DataType.FLOAT32)
tensorImage.load(bitmap)
val processed = imageProcessor.process(tensorImage)
interpreter.run(processed.buffer, outputBuffer.buffer)

Applied ML feels most rewarding at the exact moment a model leaves the notebook and runs reliably in someone's pocket.

Wildan Fatahillah Akbar

Written by Wildan Fatahillah Akbar

ODP IT at Bank Negara Indonesia (BNI) sharing notes on banking tech, Android, ML, and ideas. Want to continue the conversation? Say hi on LinkedIn or via email.