From Blight to Bright: Building an AI-Powered Web App for Small-Scale Potato Farmers

It’s been quite a journey—9 months of learning, coding, debugging, and frequent (okay, sometimes excessive) cups of coffee. I’ve faced the highs and lows of creating an AI-powered web application to diagnose potato diseases, providing farmers with not just diagnoses but also recommendations on treatment procedures, nearby shops, and agrovets and continuous mentorship and guidance through our free resources. All this while juggling my university degree, leading tech community initiatives, and hustling to make ends meet. There were moments when I nearly called it quits, having to call off the ALX Software Engineering program twice and almost giving up. Despite the challenges, I pushed through the chaos to reach the finish line of my final project

Why Potato Farming? A Personal Journey

Growing up in Kenya, Oyugis to be precise or ‘piny machwe’ as my grandmother would say to mean a fertile place. I was surrounded by the vibrant colors of our agricultural landscape. From the bustling markets of Karogo to the lush fields of Kabondo, farming wasn’t just a part of life—it was life. So when it came time to choose a project for my final project for the ALX Software Engineering, I knew I wanted to make a meaningful impact on something close to my roots. Yes!

In 2018, my family faced a harsh reality: our potato crops were devastated by blight. Despite our best efforts, the lack of timely diagnosis and treatment led to significant losses. I remember the frustration of seeing those once-promising plants wither away, feeling helpless as the situation worsened. It was a tough lesson in how much knowledge and access can influence outcomes in farming.

That experience planted a seed in my mind. How could technology—my passion and field of expertise—help prevent such losses? I wanted to create something that could empower farmers with the tools they need to identify and treat crop diseases effectively.

When the opportunity to choose a project for my final year came, it was clear: I wanted to build an AI-powered solution that could make a real difference. Combining my background in backend development and machine learning with a cause I deeply cared about felt like a perfect match. It wasn’t just about coding; it was about solving a problem that had affected me personally.

So, here we are. With a dedicated team and a lot of hard work, we’ve developed a web application that aims to transform potato farming in Kenya. It’s my way of turning past challenges into a hopeful solution, and I couldn’t be more excited to see it in action.

Project Accomplishments: Transforming Potato Farming with AI

Project Outcome

Our AI-powered web application is now up and running, offering small-scale farmers in Kenya a revolutionary tool to diagnose potato diseases. By leveraging image recognition technology, the application provides timely and accurate diagnoses, along with recommendations on treatment procedures, nearby shops, and agrovets. This empowers farmers to take immediate action to safeguard their crops, boosting productivity and reducing losses.

Technology Choices and Rationale

  1. Frontend Development: We used HTML5, CSS3, and JavaScript for the frontend. This choice was made to ensure a clean, responsive design without the added complexity of additional frameworks. By focusing on these core technologies, we aimed to create a robust, adaptable interface that works well on various devices.

  2. Backend and Machine Learning: For the backend, we utilized Django to build a scalable and reliable web application. Django’s robust framework facilitated seamless integration with our machine learning model, while its built-in features accelerated development. We chose TensorFlow and Convolutional Neural Networks (CNNs) for the machine learning component to accurately classify potato diseases based on leaf images. TensorFlow’s extensive library support and CNNs’ ability to learn complex patterns were crucial for our model’s accuracy.

  3. API and Database: FastAPI was selected to handle API requests due to its lightweight, high-performance nature, which complements our needs for rapid data processing and response. MySQL was used for data storage, providing a reliable database solution for managing user data and disease information.

Key Features Completed

  1. Image Diagnosis: Farmers can upload or capture images of potato leaves through the web platform. Our AI model processes these images, identifies the disease, and provides a detailed diagnosis along with treatment options.

  2. User Authentication: We implemented a secure login and registration system to manage user access and data, ensuring that farmers can easily access their diagnostic history and personalized recommendations.

  3. Responsive Design: The application is designed to be fully responsive, making it accessible on both desktop and mobile devices. This ensures that farmers can use the tool regardless of their device or internet connectivity.

Taming the AI: Overcoming Model Accuracy Issues

One of the most challenging aspects of our project was ensuring the accuracy of our AI model for diagnosing potato diseases. This was crucial, as the effectiveness of our application hinged on the model’s ability to provide reliable diagnoses.

  1. Situation

Early in the development phase, we faced significant issues with the accuracy of our convolutional neural network (CNN). Despite having a solid dataset and a well-defined model architecture, the model was struggling to distinguish between similar symptoms of potato diseases. The accuracy was well below the acceptable threshold, which posed a risk to the project's success.

  1. Task

My task was to improve the model’s accuracy to ensure reliable diagnosis for farmers. This involved not only fine-tuning the existing model but also experimenting with various techniques to enhance performance. Given the importance of this feature, there was a pressing need to resolve the issue swiftly to keep the project on track.

  1. Action

I started by diving deep into the data and model parameters. After reviewing the dataset, I discovered that the training images were not sufficiently varied in terms of lighting conditions and leaf angles. To address this, I augmented the dataset with additional images and applied techniques like rotation, scaling, and color adjustments. This helped simulate real-world conditions more effectively.

  1. Next,

I experimented with different CNN architectures and hyperparameters. I utilized TensorFlow’s extensive library to test various configurations, including different layers and activation functions. Additionally, I implemented transfer learning by using a pre-trained model as a starting point, which provided a better baseline for our specific task.

Despite these efforts, the model still faced challenges. The breakthrough came when I decided to implement advanced data augmentation strategies and employ a more sophisticated model architecture. After several iterations, I managed to achieve a significant improvement in accuracy (83%). The model’s performance was validated using a separate test set, and it successfully met the accuracy requirements.

Result

The enhanced model achieved a reliable accuracy rate (83%), allowing the application to provide accurate diagnoses of potato diseases. This success not only validated our approach but also ensured that farmers could trust the recommendations provided by our application. The experience underscored the importance of thorough data preparation and model tuning in achieving a robust AI solution.

Lessons Learned: From Code to Insights

  1. Technical Takeaways

One of the most profound technical insights from this project was the critical importance of data quality and preprocessing in machine learning. Initially, I underestimated how much the quality and diversity of training data could affect model performance. Through this project, I learned that well-curated and augmented datasets are fundamental to achieving reliable AI outcomes. Implementing advanced data augmentation techniques and experimenting with various CNN architectures were key to improving the model’s accuracy.

Additionally, integrating different technologies seamlessly was a valuable lesson. Using TensorFlow for machine learning, FastAPI for the backend, and Django for the web interface highlighted the importance of choosing the right tools for each component and ensuring they work well together. This experience reinforced the significance of thoughtful technology selection and system integration.

2. What I Might Do Differently

Looking back, I would have started data augmentation and model experimentation earlier in the project. Allocating more time for these crucial steps would have allowed for more iterations and refinements, potentially leading to an even better-performing model. Additionally, involving domain experts earlier in the process could have provided valuable insights into specific challenges faced by farmers, leading to more targeted solutions.

3. Self-Discovery as an Engineer

This project revealed my resilience and adaptability as an engineer. Tackling complex problems like model accuracy and system integration required me to think critically and persevere through challenges. I discovered a genuine passion for solving real-world problems through technology, and I learned that I thrive under pressure when working on impactful projects.

4. Future Engineering Path

This experience has solidified my interest in backend engineering and machine learning. The challenges and successes of this project have guided me towards specializing in these areas for the next phase of my career. I’m particularly excited about the potential of combining backend development with advanced AI techniques to create scalable and innovative solutions.

Confirmations and Questions

One belief that was confirmed during this project is the power of hands-on experimentation in learning. The iterative process of testing, tweaking, and validating models underscored the value of practical experience over theoretical knowledge. Conversely, I questioned the assumption that a single model architecture can fit all scenarios. This project demonstrated that tailoring solutions to specific problems and datasets is crucial for achieving optimal results.

Overall, this project has been a transformative experience, providing me with technical skills, personal insights, and a clear direction for my future in engineering.

About the Author

I'm Daltone Otieno, a passionate software engineer and machine learning enthusiast specialising in building AI-powered solutions to solve real-world problems. My goal is to leverage technology to create impactful solutions for communities.

Project Landing Page

LinkedIn

X