1. Introduction
Ingestion of poisonous mushroom species can cause severe life-threatening failure of organs in humans. Every year numerous food poisoning cases come up due to misidentification of mushrooms around the world. This issue is also prevalent to certain regions of India like Jammu & Kashmir, Himachal Pradesh, Uttarakhand, and Northeastern states. Also, wild mushrooms are part of diet of tribal and ethnic groups of India residing in hilly areas of India. 53 patients with mushroom poisoning were admitted to Meghalaya over the five-year study period (2014–2019) [
1]. In recent years it is reported that in the tribal region of Central India, 209 cases of mushroom food poisoning were registered. Most cases (171 out of 81.81%) came from rural areas, while 86% of cases belonged to lower socioeconomic classes. The winter season accounted for 109 (52.15%) of these cases, with summer coming in second at 69 (33.11%) and rainy season at 31, 14.83 percent [
2].
To mitigate the issue of misdetection of Mushrooms, many researchers have come up with Image Based CNN for predicting the edibility of Mushrooms [
3,
4]. However, no such smartphone applications are available In India till now. Therefore, an approach has been made to develop an application for the prediction of poisonous and edible mushroom from images. The current study uses CNN algorithm for building the predictive models and then deploy into a smartphone application to predict the edibility of Mushrooms from its image.
2. Methodology
Data Collection
The dataset used for training CNN model was downloaded from GitHub provided by the Danish Svampe Atlas for 2018 Fungi Classification [
5,
6] for research purposes. Dataset contains over 100,000 fungi images of nearly 1,500 wild mushrooms species.
Categorization of Mushrooms into Poisonous and Edible Mushrooms
The information of Poisonous and Edible Mushroom species was collected from mainly three web portals – First nature [
7], Monaco nature encyclopedia [
8] and MyKoweb [
9]. These web portals contain extensive and detailed information regarding shape, color, size, smell, distinctive features and also its edibility. In these portals, edibility for only 122 mushrooms could be found. Out of 122 species, 57 species were found out to be edible and 65 species were poisonous.
Removal of Unwanted Background from Mushroom Images Using U2 Net Image Segmentation Model
The images present in the collected dataset often contains unwanted objects. Training a CNN model with such images or images having objects not related to output label might confuse the deep learning model. To remove such objects from the images, a python library named
rembg was used. This library uses an image segmentation CNN model called U
2Net [
10] that recognizes the edge or boundary of an object and extracts it into a new image.
Selection of Mushroom Species for Model Training While Maintaining Data Balance
A total of 14 mushroom species was selected for training where 7 species belonged to poisonous species and other 7 species belonged to edible mushroom species. These were selected such that equal number of both poisonous and edible species was taken having same genus.
Data Augmentation
To increase size or number of images, data augmentation was performed by rotating images, increasing and decreasing brightness and adding small amount of blurring.
For every mushroom image, a total of 5 augmented images were created.
No of image for each species = 32
No of images after augmentation = 32 x 5 + 32= 192
Therefore, total poisonous mushroom images = 192 x 7 = 1344
Total edible mushroom images = 192 x 7 =1344
3. Model Development on Top of InceptionV3 Pretrained on ImageNet Dataset
InceptionV3 pretrained on ImageNet dataset was used as the based model for the CNN model. InceptionV3 is a 48 layers CNN model consisting of 27 convolutional layers, 13 pooling layers, and 8 fully connected layers. The last layer is a Global average pooling layer followed by a Dense layer with 1000 neurons.
For training it on Mushroom images, the last layer of Inceptionv3 was removed and a layer of 128 neurons was attached followed by a single layer of 1 sigmoid neuron. And the model accepts an image with input shape of 299 x 299 x 3.
4. Model Evaluation
For training the CNN, SGD optimizer was used which resulted in lower training time and better prediction accuracy. To test or evaluate the trained model, a minimum of 16 mushroom images for each species was kept separated and not used in the training set. Below is the model’s performance on both edible and poisonous species in
Table 1 and
Table 2 respectively. From
Table 1, it can be seen that considering all the species, the overall accuracy for predicting edible mushroom is ≈ 62.5 %. Similarly, from
Table 2, the predictive accuracy of the model for poisonous mushroom is 85.45%.
5. Deployment of Model into Android App
After exporting the trained model to h5 file format, the file has been converted to
tflite model to integrate it into an Android App. The development of the application was done on Android Studio using java programming language. The application has the functionality to either capture an image of a mushroom or pick from gallery of the device for prediction of the edibility of the mushroom. The detailed methodology followed in this study has been depicted in
Figure 1.
Conclusion
It is evident that the accuracy of the Deep learning CNN model is not quite good due to low number of training images of Mushroom. Enhanced training dataset can significantly improve the accuracy of the Model. Alternative approaches like dual or multibranch CNN can be used to train on both top view and bottom view of mushroom images at once. This can significantly help the model to identify and distinguish between a poisonous and edible mushroom species.
References
- Pandita, K. K.; Topno, N.; Thappa, D. M. Mushroom poisoning and outcome of patients admitted in a tertiary care hospital in North East India. Journal of Medicine in the Tropics 2021, 23(1), 29–34. [Google Scholar] [CrossRef]
- Sharma, M. D.; Vaishnao, L. S.; Kewalramani, M. S.; Aggrawal, R. P.; Jawade, A. S.; Bathe, A. A. A Retrospective Observational Study of Poisoning Cases Admitted in a Tertiary Care Teaching Institute in a Tribal Area of Central India. Indian Journal of Forensic Medicine & Toxicology 2019, 13. [Google Scholar]
- Ketwongsa, W.; Boonlue, S.; Kokaew, U. (2022). A new deep learning model for the classification of poisonous and edible mushrooms based on improved alexnet convolutional neural network. Applied Sciences 2022, 12, 3409. [Google Scholar] [CrossRef]
- Wang, B. Automatic Mushroom Species Classification Model for Foodborne Disease Prevention Based on Vision Transformer. Journal of Food Quality 2022, 2022. [Google Scholar] [CrossRef]
- Fungi Classification 2018. https://sites.google.com/view/fgvc5/competitions/fgvcx/fungi. Last accessed December 2024.
- 2018 FGVCx Fungi Classification Challenge. https://github.com/visipedia/fgvcx_fungi_comp.
- First Nature. https://www.first-nature.com/. Last accessed December 2024.
- Monaco Nature Encyclopedia. https://www.monaconatureencyclopedia.com/ Last accessed December 2024.
- MykoWeb. https://www.mykoweb.com/ Last accessed December.
- Qin, X.; Zhang, Z.; Huang, C.; Dehghan, M.; Zaiane, O. R.; Jagersand, M. (2020). U2-Net: Going deeper with nested U-structure for salient object detection. Pattern recognition 2020, 106, 107404. [Google Scholar] [CrossRef]
- Culjak, Ivan, David Abram, Tomislav Pribanic, Hrvoje Dzapo, and Mario Cifrek. "A brief introduction to OpenCV." In 2012 proceedings of the 35th international convention MIPRO, pp. 1725-1730. IEEE, 2012.
- Bradski, Gary, and Adrian Kaehler. Learning OpenCV: Computer vision with the OpenCV library. O'Reilly Media, Inc., 2008.
|
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).