Skip to content

Classifying coffee beans (Green/unroasted Light, Medium, Dark) using CNNs (Effnet)

License

Notifications You must be signed in to change notification settings

sehyunlee217/coffee_bean_multi_classification

Repository files navigation

Classifying coffee beans based on level of roasting using CNN Models (Effnet)

Screenshot 2024-07-15 at 17 20 24


Drinking coffee in the morning is one of the most important things that many do to start the day. While several elements contribute to a good cup of coffee, understanding the types of beans and their roasting levels is key to mastering your morning coffee.

For this dataset, four roasting levels with its bean type are addressed: Green/Unroasted and lightly roasted coffee beans are Laos Typica Bolaven. Doi Chaang are the medium roasted, and Brazil Cerrado are dark roasted. All coffee beans are Arabica beans.

Green/Unroasted

green

Lightly Roasted

light

Medium Roasted

medium

Dark Roasted

dark

Two CNN models were tested against each other to determine which model was more suitable for this multi-classification problem. As the problem involves classifying four different classes and the model was to be run on Hugging Face Spaces, a smaller model was deemed adequate and preferred due to size limitations. Effnet B1 and Effnet V2 S were evaluated based on their loss and accuracy.

Both models were trained on 300 images per class (4 roasting types) and tested on 100 images per class.

Since this is a multi-classification problem, the cross-entropy loss function was used with the Adam optimizer. Both models were trained for 5 and 10 epochs, which was sufficient for this straightforward classification problem.

Test Accuracy (Effnet B1 v.s Effnet_v2_s)

Screenshot 2024-07-15 at 17 33 16

Test Loss (Effnet B1 v.s Effnet_v2_s)

Screenshot 2024-07-15 at 17 33 30

Both models performed very well, achieving over 98% test accuracy and demonstrating very low loss. However, given that Effnet B1 has a size of 26MB compared to Effnet V2 S’s 81MB and the training time of Effnet V2 S taking double of B1, Effnet B1 was deemed more appropriate for this project.

Additionally, prediction probabilities were not the highest for medium vs. dark roasted beans, as both can be often easily mistaken for one another. The overall prediction labels were accurate; however, the model lacked confidence when differentiating between these two types. This difficulty was understandable upon examining the photos.

One is dark and one is medium here, but it is difficult even for the human eye to distinguish between the two due to the location of shadows and image quality.

medium (20) dark (64)

In conclusion, while both CNN models demonstrated high accuracy and low loss, Effnet B1 was selected as the more suitable model due to its smaller size, making it more practical for deployment on Hugging Face Spaces. Despite the overall high prediction accuracy, distinguishing between medium and dark roasted beans proved to be challenging, due to shadows in the images. Future improvements could focus on enhancing the model’s ability to differentiate between these closely related classes and also adding different types of beans and its shapes as well.


Dataset from Coffee Bean Data | Ontoum, S., Khemanantakul, T., Sroison, P., Triyason, T., & Watanapa, B. (2022). Coffee Roast Intelligence. arXiv preprint arXiv:2206.01841.

About

Classifying coffee beans (Green/unroasted Light, Medium, Dark) using CNNs (Effnet)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published