billion insights by rkb

AI in agricultural production starts after the harvest

Grading mangoes and strawberries, weighing fruit without a scale and counting coconuts on a conveyor: what our research says about where AI helps farms and food processors.

AI Applications and SystemsIndustrial AI and Data

Discussions of AI in agriculture tend to focus on the field: drones, satellite imagery, smart irrigation. Those matter. But much of a crop’s value is decided after it is picked, when someone sorts it, weighs it, counts it and decides which market it goes to. In the Philippines, most of that work is still done by hand.

The stakes are large. The Philippines is one of the world’s leading mango exporters, and the Carabao mango alone made up about 81% of national mango production in early 2019. Coconut is grown on about 3.65 million hectares, and coconut oil is among the country’s top agricultural exports. Yet sorting is often manual, which makes it slow, labor-intensive and inconsistent: two sorters can judge the same fruit differently.

Over several years, my colleagues and students at De La Salle University’s Intelligent Systems Laboratory and I have worked on this postharvest stage. Five papers, covering four problems, show what AI can realistically do there and what it takes to make it work.

Grading fruit to a national standard

Our earliest work in this area, with support from the Philippine Center for Postharvest Development and Mechanization (PHilMech) and the engineering firm Neuronmek, built a machine that sorts Carabao mangoes into good and bad. Two design choices made the difference:

  • Labels came from the Philippine National Standard for mangoes. A fruit was “good” only if it was free of the defects, insect damage and injuries the standard describes. The AI learned the grading rules that buyers already use, not a definition invented for the project.
  • The camera saw the whole fruit. Earlier systems photographed one side of a mango, so a defect on the other side went unnoticed. Our conveyor used rollers and solenoids to turn each mango in front of the camera, capturing it from several sides.

The hardware was modest: a webcam, controlled lighting, a plain background and a Raspberry Pi running a convolutional neural network. The final model classified mangoes with about 97% accuracy, and the setup could sort up to roughly 870 mangoes an hour.

The development history was just as instructive. When the system moved from the test rig to the more industrial sorting machine, accuracy dropped to about 91% until the model was retrained on images from the new setup. A model that performs perfectly on one machine is not automatically ready for the next.

Weighing without a scale

Appearance is only one part of grading. Mangoes are also sold by size and weight, which the 2019 work flagged as the next step. A later study tackled this directly: estimating each mango’s weight from video as it moves along a conveyor.

The model used four simple measurements from the video: length, width and two pixel counts. These features were strongly correlated with actual weight, and a deep learning model that combined three types of sequence layers produced estimates with an average error of about 2.6% and explained 98.5% of the variation in weight. For a packing line, that means weight grading without stopping the fruit or handling it more than necessary.

Extending quality checks to small growers and sellers

Strawberries pose a different challenge. They are delicate, and uncut strawberries can lose quality within one to two days without refrigeration. In this study, the main obstacle was not the algorithm but the data. Public strawberry datasets were small, fewer than 500 images per class, so the team photographed additional fruit and built a balanced set of 1,300 images labeled desirable or undesirable.

A compact neural network trained on this data reached 98.4% training accuracy and 92.8% validation accuracy, and correctly classified all 200 test images. That is a promising start rather than proof of field performance, but it points to an important use case: the study recommends putting the model in a mobile app so that small merchants and consumers, not only large packing plants, can check quality.

Counting product in the processing plant

The most recent study moved from the packing line to the processing plant. A coconut by-product manufacturer in Misamis Oriental counted dehusked coconuts on a conveyor with photoelectric sensors that were only about 88% accurate, limited by their short range and narrow detection angle.

We replaced them with a camera and an object detection and tracking pipeline. The detector reached 97.9% average precision, and in three test videos the system counted between 91.8% and 97.8% of the coconuts that passed, even though the nuts roll unpredictably and dirt is present on the line. The remaining errors came from low-resolution frames and cluttered backgrounds, which better cameras with higher frame rates can address. Reliable counts give the plant a basis for production analysis and planning.

What these studies have in common

  1. Postharvest is where AI pays off first. Grading, weighing and counting decide price, market access and production planning. They are also repetitive and visual, which suits computer vision.
  2. Low-cost hardware is enough to start. A webcam, a phone camera and a Raspberry Pi were sufficient for useful results. The investment that matters most is in data and setup.
  3. Local data is the real bottleneck. Philippine crops, varieties and defects are poorly represented in public datasets. Teams have to build their own, balance the classes and label them against the standards buyers use.
  4. Controlled conditions flatter the model. Accuracy fell when the mango sorter moved to a new machine, and counts in live video were lower than detection scores. Validate on the actual line, and plan for retraining when equipment, season or variety changes.
  5. Grading should be about routing, not just rejecting. Some markets accept fruit with minor defects, and slightly blemished mangoes can still become dried mango. Classifying the type and severity of a defect, not only good or bad, can reduce waste and raise farm income.

A practical sequence for agribusinesses and cooperatives

  1. Choose one costly decision. Grading, weight classing or product counts, wherever mistakes or delays cost the most.
  2. Define labels from the standard your buyers use. National standards and export specifications make the AI’s output meaningful to the market.
  3. Build a local dataset. Cover varieties, seasons and defect types, and keep the classes balanced.
  4. Control the scene. Consistent lighting, a clean background, a full view of each item and a camera fast enough for the conveyor.
  5. Pilot on the real line. Compare the system with manual results over full shifts before relying on it.
  6. Link grades to markets. Send each grade to fresh export, local sale or processing, so better sorting turns into better prices.

These projects also show the value of partnership. Universities can develop the models, government agencies such as PHilMech know the standards and the growers, engineering firms build the machines, and plants provide the real conditions to test them. AI in agricultural production works best when all four are at the table.

More insights