Deep learning boosts food freshness detection

Mansi Bhandari

Mansi Bhandari


Imagine a world where you don’t have to throw away that extra pack of strawberries, a world where all of the grapes in the store are ripe, and where all of your food is fresh and flavourful.

Freshness detection in agriculture refers to the process of assessing the quality and ripeness of agricultural products, such as fruits and vegetables, to determine their suitability for consumption or further distribution. Yue Yuan and Xianlong Chen’s new study, “Vegetable and fruit freshness detection based on deep features and principal component analysis,” has made strides in assessing the freshness of food by harnessing the power of deep learning.

Traditionally, freshness detection in agriculture has relied on manual observation and judgment by trained professionals or farmers. However, this approach is subjective, labour-intensive, and error-prone, leading to inconsistencies in quality assessment. These old ways just simply cannot meet the growing demands for high-efficiency and accurate freshness detection.

Recent advancements in computer vision, machine learning, and artificial intelligence have enabled new methods for freshness detection that are more objective, faster, and more accurate. Thanks to these advances, it is now possible to automate the visual detection of agricultural products by means of computer-mediated analysis of image and/or video data. This detection can be used to rank products according to predefined metrics of freshness.

For example, algorithms relying on computer vision can look for changes in colour, appearance, texture, and shape that might indicate the perishability of fruits and vegetables—e.g., bruising or slight spoilage—that might normally go undetected by a human eye. Machine learning models can also be trained on sites with hundreds of thousands of labelled images: drooping strawberries might constitute subtle clues to their perishability that, if highlighted for a human reviewer, can make the method more reliable.

Deep Learning and Principal Component Analysis (PCA)

The study introduces a new approach combining deep learning and Principal Component Analysis (PCA) to tackle the problem. Here’s a quick rundown:

  • Deep Learning: Using convolutional neural networks (CNNs), the study extracts deep features from images of fruits and vegetables. CNNs are particularly good at identifying and learning from patterns in image data, which makes them ideal for a task like freshness detection.
  • Principal Component Analysis (PCA): Once the deep features are extracted, PCA is applied to reduce the dimensionality of the data. This step is crucial as it simplifies the complexity of the data, one of the most significant features that contributes to freshness. PCA helps reduce noise and improve the performance of the subsequent classification algorithms.


The research methodology can be summarized in the following steps:

  1. Image Acquisition: High-quality images of various fruits and vegetables at different stages of freshness are captured.
  2. Feature Extraction: A pre-trained CNN model is employed to extract deep features from these images. The choice* of a pre-trained model accelerates the process and leverages the robustness of models trained on large datasets.
  3. Dimensionality Reduction: PCA is applied to the deep features to distil the essential components influencing freshness.
  4. Classification: The reduced features are then fed into a classifier to categorize the produce based on freshness levels.

*Three pre-trained deep learning models (GoogLeNet, DenseNet-201 and ResNeXt-101) were used to extract deep features of vegetable and fruit freshness.


The proposed method demonstrated high performance in detecting the freshness of vegetables and fruits. It achieved a detection accuracy of 99.95 per cent and an F1-score of 1.00 for both fresh bananas and fresh strawberries. In contrast, it performed poorly for rotten bell peppers and rotten potatoes, with detection accuracies of 99.10 per cent and recall rates as low as 92.14 per cent, respectively.

Overall, the method was highly effective, except for the lower performance with rotten bell peppers and potatoes.


Subscribe – it's free