Large-Scale classification of roasted coffee bean varieties using deep learning and machine learning methods
This study presents a large-scale classification framework for roasted coffee beans using a newly created dataset of 8,417 images, demonstrating that deep learning models, particularly EfficientNet-B0, achieve near-perfect accuracy (99.86%) in distinguishing four main varieties and eight Arabica subtypes, outperforming traditional machine learning and hybrid approaches.
Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Coffee is more than just a morning ritual; it is a global commodity where the difference between a premium bag and a cheap blend can be a matter of hundreds of dollars. Yet, once the beans are roasted, they often look nearly identical to the human eye. This visual similarity creates a vulnerability: unscrupulous sellers can mix expensive beans with cheaper ones or mislabel the origin, defrauding consumers and undermining the trust that specialty coffee markets rely on. For decades, experts have tried to solve this by tasting the beans or using complex chemical tests that require grinding the sample and running it through laboratory machines. These methods are slow, expensive, and often subjective. A newer approach, however, looks to the camera lens. By teaching computers to see the subtle textures and color variations that humans miss, researchers are developing a way to identify coffee varieties instantly and objectively. This field, known as computer vision, uses artificial intelligence to analyze images, looking for patterns that distinguish one object from another. The challenge with coffee is that the roasting process darkens the beans and makes their surfaces look remarkably similar, turning a task that is easy with green, unroasted beans into a difficult puzzle for both people and machines.
In a recent study, researchers at Başkent University tackled this puzzle by building a system capable of identifying four main types of roasted coffee beans: Arabica, Robusta, Liberica, and Excelsa. To do this, they first had to create a library of images that was far more comprehensive than anything previously available. They set up a specialized photography station in a controlled environment, using a custom-built wooden table and a light tent to ensure every photo was taken with the same lighting, angle, and distance. They photographed beans from fifteen different suppliers, capturing over eight thousand high-resolution images. Because the original photos were too large for the computer programs to process directly, the researchers broke them down into smaller, manageable squares. They then used a technique called data augmentation, which creates new training examples by flipping, rotating, and slightly changing the colors of the existing images. This process expanded their dataset to nearly 190,000 images, giving the computer a vast library to learn from. Crucially, they organized this data carefully so that images taken from the same original photo never appeared in both the training set and the test set, ensuring the computer was truly learning to recognize the beans rather than just memorizing specific pictures.
The team then tested several different artificial intelligence models, which are essentially programs designed to recognize patterns in images. They tried various architectures, including some that are known for being fast and others for being highly detailed. The most successful model was a system called EfficientNet-B0. When this model was shown images of the roasted beans, it learned to distinguish between the four main types with extraordinary precision. In tests where the model was challenged with new images it had never seen before, it correctly identified the variety of the bean in nearly 99.9 percent of cases. The researchers also tested the model's ability to tell the difference between eight different sub-types of Arabica beans, a much harder task because these beans are so similar. Even here, the system achieved an accuracy of over 99 percent, proving it could detect minute differences in texture and color that are invisible to the naked eye.
To see if a different approach might work, the researchers also tried using traditional machine learning methods, which rely on the computer finding specific features in the image and then making a decision based on those features. They tested two popular methods, Random Forest and a technique called XGBoost. While these methods performed well, with the best one achieving nearly 98 percent accuracy, they still fell short of the deep learning model. The researchers also explored a hybrid approach, where a deep learning system was used only to extract features from the images, and a traditional machine learning model was used to make the final classification. This method yielded lower accuracy than the deep learning model alone, suggesting that for this specific task, the deep learning system's ability to learn directly from the raw pixels was superior.
The study concludes that roasting does not make coffee beans impossible to distinguish; it simply requires a more sophisticated eye. By using a large, carefully curated dataset and advanced image analysis, the researchers demonstrated that a computer can identify coffee varieties with a level of consistency and accuracy that surpasses human capability. This work suggests that in the future, such systems could be used to verify the authenticity of coffee products, ensuring that consumers get what they pay for and helping to maintain transparency in the global coffee trade. The success of the study relies on the quality of the images and the rigor of the testing, showing that when the data is prepared correctly, artificial intelligence can solve problems that have long been difficult for humans to solve by sight alone.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.