ADTC Offline Crop Disease Classifier

Inspiration

My uncle lost 50% of his tomato crop to late blight last year. It was heartbreaking watching months of hard work disappear because he couldn't identify the disease early enough. This got me thinking - what if farmers could instantly diagnose crop diseases using just their phones?

I learned that Africa loses $4 billion annually to crop diseases, yet most farmers have limited access to agricultural experts. But nearly every farmer now has a smartphone. That's when it clicked - why not turn their phone into a crop disease detection tool that works anywhere, even without internet?

What it does

I built an Android app that turns any smartphone into an instant crop disease detector. You just point your camera at a crop leaf, and within 3 seconds, it tells you if the plant is healthy, diseased, or if you need to get closer for a proper reading.

The app works completely offline - no internet needed. It can identify diseases in 9 different crops including tomatoes, corn, potatoes, and apples with 87% accuracy. I also built a smart proximity system that only analyzes crops when they're close enough to the camera, preventing false readings from distant objects or walls.

The whole app is just 20MB, so it runs on even basic Android phones that cost under $100.

How we built it

I started by training an AI model using the PlantVillage dataset with over 5400+ crop images. Since I needed the app to work on phones, I used MobileNetV2 as my base model:

base_model = tf.keras.applications.MobileNetV2(
    input_shape=(224, 224, 3),
    include_top=False,
    weights='imagenet'
)
model = tf.keras.Sequential([
    base_model,
    tf.keras.layers.GlobalAveragePooling2D(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(3, activation='softmax')
])```

The tricky part was building the Android app. I learned Kotlin from scratch and used CameraX for the camera functionality. Getting real-time image processing to work smoothly took weeks of debugging.

The biggest challenge was preventing false positives. My first version would classify walls and sky as "diseased crops" - not very helpful! So I developed a proximity detection system using edge detection

## Challenges we ran into

The biggest headache was the false positive problem. My early versions were hilariously bad - they'd diagnose my bedroom wall as having tomato blight! I spent weeks figuring out how to make the app only analyze actual crops that are close enough to the camera.

Getting the model size down was another nightmare. My first model was 45MB - way too big for basic phones. I had to learn about quantization and model pruning to get it down to 20MB without losing too much accuracy.

The Android camera API nearly broke me. I must have rewritten the camera code five times before I got it working properly. Real-time image processing while keeping the UI smooth is harder than it sounds.

Testing was frustrating too. The PlantVillage dataset has these perfect, clean images, but real crops in gardens look nothing like that. I had to add noise and blur to my training data to make it work with actual leaves I collected from local gardens.

### Accomplishments that we're proud of

I'm honestly amazed this thing actually works! Getting 87% accuracy on real crop leaves I tested feels incredible. The proximity detection system I built prevents almost all false positives - it correctly ignores walls, sky, and distant objects.

The app runs smoothly on my old Android 7 phone, which proves it'll work for farmers with basic devices. And the fact that it's completely offline means it'll work in remote areas with no internet.

But what I'm most proud of is that I built something that could genuinely help farmers. Every time I test it on a diseased leaf and it correctly identifies the problem, I think about how this could have saved my uncle's crop.

### What we learned

This project pushed me way beyond my comfort zone. I learned Android development from scratch, dove deep into computer vision, and figured out how to optimize AI models for mobile devices.

The technical stuff was hard, but the real learning was about building for real users. Farmers don't want complex interfaces with lots of options - they want something simple that just works. Every design decision had to be about making it easier to use.

I also learned that real-world testing is crucial. My model worked great on clean dataset images but struggled with actual leaves until I improved the training data. There's a huge gap between lab conditions and reality.

### What's next for ADTC Offline Crop Disease Classifier

Short term, I want to add more crops - especially cassava and other African staples. I'm also working on multi-language support since not all farmers speak English.

The big vision is turning this into a complete farming assistant. Imagine if it could also identify pests, suggest treatments, and even connect farmers with local suppliers. I'm thinking about adding a community feature where farmers can report disease outbreaks in their area.

I'd love to partner with agricultural organizations to get this into farmers' hands. The technology works - now it's about distribution and making sure it reaches the people who need it most.

Eventually, I want to expand beyond Africa. Crop diseases are a global problem, and if this app can help farmers anywhere save their harvests, that would be amazing.

Built With

  • android
  • android-bitmap-api
  • android-studio
  • camerax
  • databases
  • git
  • github
  • google-colab
  • gradle
  • imagenet
  • jupyter-notebooks
  • keras
  • kotlin
  • mobilenetv2
  • model
  • mvvm-architecture
  • numpy
  • opencv
  • or-external-apis-the-app-works-completely-offline
  • pil
  • plantvillage-dataset
  • python
  • tensorflow
  • tensorflow-lite
  • transfer-learning
Share this project:

Updates