Kontak Kami

Artikel | Opini

Bacteria Classification using Image Processing and Residual Neural Network (ResNet)

28 Agu 2026

Oleh: Dybio Dompu Hot Asih, Adnan Purwanto, Dwiza Riana, dan Sri Hadianti – Universitas Wirahusada Medan

SEVIMA – Detection of microorganisms is of particular importance to human health and life, and for the industry in general. For this reason, we want this process to be as fast and precise as possible. We also expect that the automation of this activity (detection of microorganisms) can be widely used in various industries. This article is another attempt to the classification of bacteria that uses a deep learning approach with Residual Neural Network(ResNet) models. The research was conducted by training the ResNet-18,ResNet-34, ResNet50 and ResNet-101 models. The results show that the ResNet-50 and ResNet-101 are the best learning model. It is better to use ResNet-50 than ResNet- 101 because of the faster training time. While the results of the research also show that the architecture with the least number of layers is the fastest learning model. ResNet-50 has an accuracy rate of 96.1% with a training time of 451 seconds is the best learning model. ResNet-18 has an accuracy rate of 93.6% with a training time of 185 seconds is the fastest learning model.

Bacteria Classification and the Role of Deep Learning

The rapid growth of technology has initiated the development of automated system in various fields, including medical[1] and microorganisms. Bacteria can be either bad or good to human body such as lactobacillus, a good bacteria that can improve Symptoms of Irritable Bowel Syndrome or Escherichia coli, a bad bacteria that produces a potent toxin that can harm the lining of the small intestine. There are 2 main methods to classify bacteria.

First, bacteria can be classified based on their cell wall composition and reaction to the Gram stain test. This method can classify bacteria to positive gram as shown in Fig. 1(a) and negative gram as shown in Fig. 1(b). Second, bacteria can be classified by shape such as Cocci, Bacili and Spirilla as shown in Fig 1(c) until Fig 1(e). This shows that there are many types of bacteria and to classify bacteria for diagnosis is going to be rough and need to take time[2].

Fig 1. Classification of Bacteria

A Convolutional Neural Network (ConvNet/CNN) is a Deep Learning algorithm which can take in an input image, assign importance (learnable weights and biases) to various aspects/objects in the image and be able to differentiate one from the other. The pre- processing required in a ConvNet is much lower as compared to other classification algorithms. While in primitive methods filters are hand-engineered, with enough training, ConvNets have the ability to learn these filters/characteristics[3].

The architecture of a ConvNet is analogous to that of the connectivity pattern of Neurons in the Human Brain and was inspired by the organization of the Visual Cortex. Individual neurons respond to stimuli only in a restricted region of the visual field known as the Receptive Field. A collection of such fields overlap to cover the entire visual area[4].

Similar to the Convolutional Layer, the Pooling layer is responsible for reducing the spatial size of the Convolved Feature. This is to decrease the computational power required to process the data through dimensionality reduction. Furthermore, it is useful for extracting dominant features which are rotational and positional invariant, thus maintaining the process of effectively training of the model[5].

ResNet is an architecture from CNN which introduces a new concept, namely shortcut connections. The emergence of the concept of shortcut connections that exist in the ResNet-50 architecture is related to the vanishing gradient problem that occurs when efforts to deepen the structure of a network are carried out. ResNet-101 is a convolutional neural network that is 101 layers deep. You can load a pretrained version of the network trained on more than a million images from the ImageNet database[6]. The pretrained network can classify images into 1000 object categories, such as keyboard, mouse, pencil, and many animals. As a result, the network has learned rich feature representations for a wide range of images. The network has an image input size of 224-by-224.

Image Processing is a method for processing images (Image) into digital form for a specific purpose. At first this image processing functioned to improve and improve the quality of an image, but with the development of the times and the emergence of computational sciences it allows humans to retrieve the information contained in an image. The input is an image (image) and the output is an image that has been improved in quality. For example, an image that is less sharp in color, blurred (blurring) and contains noise (eg white spots) requires processing to improve image quality so as to obtain better information[7].

So far the deep learning approach in the analysis of microbiological images taking into account microbial detection and classifification was undertaken and described in several papers.Zielinski et al. [8] developed public available DIBaS (Digital Image of Bacterial Species) data set containing 660 images of 33 different microbes (fungi and bacteria). They used DSIFT, CNN,Fisher Vectors for features extraction, and for classification: SVM, random forest. The final classification result of single microbes was at the level of 97.24 +/- 1.07%. The same data set (DIBaS) was also used by Mohamed et al. [9] in the Bag of Words approach with SVM for 10 different microorganisms (10 * 20 = 200 images). This test ended with a final score of 97% correctness of classification.

With the exponential growth of data and complexity of systems, fast machine learning/artifificial intelligence and computational intelligence techniques are highly required [10]. For this research, Residual Neural Network (ResNet) a popular deep learning model that is widely used for image classification is used to classify 33 species of bacteria dataset from DIBaS dataset (Digital Image of Bacterial Species). Our focus in this research is to compare the accuracy and training time between ResNet models, namely ResNet-18, ResNet-34, ResNet-50 and ResNet-101. We resize images to compromise our hardware limitations without trying to reduce accuracy.

Hypothesis that we propose in this study is:

  • H0= all model of ResNet have equal accuracy
  • Ha= at least one model of ResNet is different accuracy
  • H0= all model of ResNet have equal training time Ha= at least one model of ResNet is different training time

Research Method: Dataset, Image Processing, and ResNet Models

In Fig. 3, we present the research method which we describe as follows

Data Set

In this study, we used the DIBAS dataset[8] consisting of 33 classes from 679 images. Example of images shown in Fig 2.

Fig 2. Example of bacteria images

Research Model

DIBAS Data Set → Image Augmentation → Color Masking → ResNet Model → Classification → Normality Test → Homogeneity Test → Comparison Test → Result

Fig 3. Research Model

Image Augmentation

Data augmentation is a commonly used technique for increasing both the size and the diversity of labeled training sets by leveraging input transformations that preserve output labels. In computer vision domain, image augmentations have become a common implicit regularization technique to combat overfitting in deep convolutional neural networks and are ubiquitously used to improve performance. While most deep learning frameworks implement basic image transformations, the list is typically limited to some variations and combinations of flipping, rotating, scaling, and cropping. Moreover, the image processing speed varies in existing tools for image augmentation[11].

Color Masking

HSV segmentation is a separation process object with color selection by value Hue, Saturation, and Value. Hue is attribute that represents pure color. Saturation is an attribute that indicates the effect of white light that affect the degree of color dominance. Value is an attribute that indicates brightness difference in pure color[12].

ResNet Model

In this study, we used 4 ResNet models namely ResNet-18, ResNet-34, ResNet-50, ResNet-101. ResNet was developed by Kaiming He et al. [11] in 2016. A residual learning method was proposed to train deeper networks that are practically difficult to train. Network layers were reformulated to learn residual functions with reference to the layer inputs[13].

The difference between each model on ResNet can be seen in Fig. 4.

Fig 4. ResNet Model

Classification

Classification is a task that requires the use of machine learning algorithms that learn how to assign a class label to examples from the problem domain[14]. Output from this task for this reseach are accuracy and training time.

Normality Test

Before conducting a comparison test of the four models, we perform data normality testing using Shapiro-Wilk test. Data normality testing is a common practice before the statistical method. Normality test is one part of the test requirements for data analysis or commonly called classical assumptions. The purpose of the normality test is to find out whether the data distribution  follows  or  approaches  the  normal distribution. The standard normal distribution is the most important continuous probability distribution has a bell-shaped density curve described by its mean and SD and extreme values in the data set have no significant impact on the mean value. If a continuous data is follow normal distribution then 68.2%, 95.4%, and 99.7% observations are lie between mean ± 1 SD, mean ± 2 SD, and mean ± 3 SD, respectively[15].

For a data normality test, the hypothesis are as follows:

  • H0: Data follow a normal distribution.
  • Ha: Data do not follow a normal distribution.

Homogeneity Test

Purpose homogeneous test is to find out homogeneous for a variance across groups [16]. We perform homogeneous testing using Levene’s test For homogeneous test, the hypothesis are as follows :

  • H0: Variance across group is not homogeneous.
  • Ha:Variance across group is homogeneous.

Comparison Test

In this research, we compared 4 models, so we used ANOVA if the data were normal and homogeneous. Meanwhile, if the data is not normal or homogeneous, we use the Kruskal-Wallis rank sum test[24]. In addition, ANOVA requires data with a sufficient number of samples [17]. In this research, each model was tested 30 times.

Results: Image Processing and ResNet Training

Image Augmentation

Each image we resize to 224 X 224 pixels. The dataset must be increased by Image Augmentation, this process will double the size from 20 files each to 40 files by using flipping and rotation techniques. Example result of flipping and rotation can be seen in Fig.5.

Fig 5. Example of flipping and rotation

Color Masking

The background color is an unnecessary feature, so the second stage is to deal with background color via Image Processing. HSV color-space is the method we used because the default colors in the RGB color-space are coded using the three channels, it is more difficult to scope the background color. So, the background was removed in this process. Example result of color masking can be seen in Fig. 6.

Fig 6. Example of Color Masking

ResNet Model

Now, the whole dataset is ready, next is to build a Residual network (ResNet) by using Fastai with Pytorch as backend. Before the training session, dataset was split into 2 parts: Training set and Test set with 80:20 ratio for the model training and evaluating. This approach used 8 epoch, 17 step per pochs, batch size at 32.

Discussion: Classification Performance and Statistical Testing

Classification

The classification results in one test will appear as shown in the Fig 7.

Fig 7. Example output result classification

Result of accuracy classification each model after 30 times test shown in table 1 and table 2.

Table 1. Result Accuracy Test

NoResnet-18ResNet-34Resnet-50ResNet-101
10.9555560.9481480.970370.955556
20.9481480.9185190.970370.925926
30.9555560.9185190.970370.962963
40.9333330.9111110.9629630.962963
50.9481480.9259260.9555560.985185
60.9555560.9185190.9777780.97037
70.9333330.9481480.9629630.955556
80.9333330.9185190.9629630.977778
90.9333330.9185190.9777780.962963
100.9333330.9259260.9555560.948148
110.9185190.9333330.9629630.985185
120.9333330.9333330.970370.985185
130.9555560.9259260.970370.977778
140.9407410.9111110.9629630.940741
150.9333330.9037040.970370.948148
160.9407410.9481480.9555560.955556
170.9259260.9111110.9555560.977778
180.9333330.9555560.9481480.940741
190.9555560.9259260.970370.97037
200.9259260.9481480.9407410.955556
210.9259260.9333330.9481480.955556
220.9407410.9481480.9851850.97037
230.9185190.9629630.9629630.955556
240.9111110.9185190.9555560.962963
250.9407410.9481480.9407410.962963
260.9111110.9555560.9555560.925926
270.9185190.9555560.9555560.97037
280.9185190.9407410.9555560.97037
290.9555560.9555560.9629630.940741
300.9407410.9407410.9407410.948148

Descriptive statistical test results are shown in the table 2.

Table 2. Descriptive Statistic Accuracy Test

NoModelCountMean
1ResNet-18300.936±0.0138
2ResNet-34300.934±0.0168
3ResNet-50300.961±0.0111
4ResNet-101300.960±0.0160

Fig 8. Box plot of Accuracy Test

Box plot of the accuracy testing shown on Fig8. The results show that the architecture with the highest number of layers is more accurate.

Result of training time classification shown in table 2.

Table 3. Result Training Time Test

NoResnet-18ResNet-34Resnet-50ResNet-101
1196287480789
2178241481704
3185243466703
4196243464754
5175243468714
6184245467772
7196248465770
8196252464777
9185246536770
10173256507773
11197258530776
12182254516771
13176251475787
14175262469813
15185261476812
16196265475813
17175263470709
18183272427624
19197265428815
20174263387709
21183256387623
22208258426793
23174265390626
24190258429714
25195256405769
26174269425620
27183263408714
28196266402773
29174271428618
30183261384714

Descriptive statistical test results are shown in the table 4.

Table 4. Descriptive Statistic of Training Time

NoModelCountMean
1ResNet-1830185±9.73
2ResNet-3430258±10.4
3ResNet-5030451±42.6
4ResNet-10130737±63.0

Fig 9. Box plot of Training Time

Box plot of the training time testing shown on Fig9. The results show that the architecture with the lowest number of layers is faster learner.

Normality Test

Table 5. Shapiro-Wilk Test of Accuracy

 WAsymp. Sig
Residual0.982850.1309

Using R Studio software, rejection and acceptance of hypothesis are seen from Asymp. Sig. (2-tailed) value. Because the number of samples is less than 50, the test results used are the Shapiro-Wilk test. If the Asymp. Sig. (2-tailed) value of Shapiro-Wilk test is greater than 0.05, the data are normal. If it is below 0.05, the data significantly deviate from a normal distribution. Based on table5, the result shows that the Asymp. Sig. (2-tailed) value of accuracy are 0.1309, thus the null hypothesis is accepted. The conclusion from the Shapiro-Wilk test shows that the data of accuracy follow a normal distribution.

Table 6. Shapiro-Wilk Test of Training Time

 WAsymp. Sig
Residual0.924574.481e-06

Based on table 6, the result shows that the Asymp. Sig. (2-tailed) value of training time are below 0.05, thus the null hypothesis is rejected. The conclusion from the Shapiro-Wilk test shows that the data of training time do not follow a normal distribution.

Homogeneity Test

Table 7. Levene’s Test of Accuracy

 dfF ValueSign
Group32.67130.05073

Using R Studio software, rejection and acceptance of hypothesis are seen from Sig. value. If the Sig. value of Levene’s test is greater than 0.05, the variance across group is homogeneous. If it is below 0.05, variance across group is not homogeneous. Based on table 7, the result shows that the Sig value are 0.05073, thus the null hypothesis is rejected. The conclusion from the Levene’s test shows that the variance across group of accuracy is homogeneous.

Table 8. Levene’s Test of Training Time

 dfF ValueSign
Group315.1612.178e-08

Based on table 8, the result shows that the Sig value are below 0.05, thus the null hypothesis is accepted. The conclusion from the Levene’s test shows that the variance across group of TrainingTime is not homogeneous.

Comparative Test

Based on the results of the normality and homogeneity tests above, the accuracy can use Anova while the training time uses the Kruskal-Wallis rank sum test.

Hypothesis for accuracy :

  • H0= all model of ResNet have equal accuracy
  • Ha=at least one model of ResNet is different accuracy

Table 9. Anova Test of Accuracy

 DfSum SqMean SqF valuePr(>F)
Model30.020450.00681532.023.74e-15
Residual1160.024690.000213  

Result of Anova Test for Accuracy shown in table 9. As the Pr(>F) value is less than the significance level 0.001, thus the null hypothesis is rejected.The conclusion from Anova Testshows that there are significant differences between the models. To find out which model is different accuracy, we use Tukey HSD.

Table 10. Result Tukey HSD of Accuracy

 DiffLowerUpperP Adj
ResNet18- ResNet101-0.0244444000-0.034263360-0.014625440.0000000
ResNet34- ResNet101-0.0266666000-0.036485560-0.016847640.0000000
ResNet50- ResNet1010.0009876667-0.0088312940.010806630.9936535
ResNet34- ResNet18-0.0022222000-0.0120411600.007596760.9349462
ResNet50- ResNet180.02543206670.0156131060.035251030.0000000
ResNet50- ResNet340.02765426670.0178353060.037473230.0000000

Result of Tukey Honest Significant Differences (HSD) show in table 10. If the P Adj value of Tukey HSD test is greater than 0.05, there are not different between two models. If it is below 0.05, there are different between two models.It can be seen from the table 5 that ResNet-50 and ResNet-101 have P Adjusted value is 0.9936535. It means that ResNet-50 and ResNet-101 have equal accuracy. ResNet-34 and ResNet-18 have P Adjusted value is 0.9349462. It means that ResNet-34 and ResNet-18 have equal accuracy. Another row in Table 10 show that another comparison model does not have P Adjusted value greater than 0.05.

Hypothesis for training time :

  • H0= all model of ResNet have equal training time Ha=at least one model of ResNet is different training time

Table 11. Kruskal-Wallis rank sum test of Training Time

Df Chi-SquaredP Value
Kruskal-Wallis3111.61< 2.2e-16

Result of Kruskal-Wallis rank sum test of Training Time shown in table 11. As the P value is less than the significance level 0.05, thus the null hypothesis is rejected. The conclusion from Kruskal-Wallis rank sum test shows that there are significant differences between the models for Training Time.To find out which model is different accuracy, we use Pairwise Wilcox Test.

Table 12. Pairwise Wilcox Test of Training Time

ResNet101ResNet101ResNet18ResNet34
ResNet183e-11
ResNet343e-113e-11
ResNet503e-113e-113e-11

Result of Pairwise Wilcox Test show in table 12. If the p value of Pairwise Wilcox Testt is greater than 0.05, there are not different between two models. If it is below 0.05, there are different between two models.It can be seen from the table 10 that every models have p value below 0.05 so every model significant difference from another models.

Conclusion

This paper showed that for accuracy, ResNet-18 and ResNet-34 have a same result. ResNet-50 and ResNet-101 have a same accuracy result. From the result testing, it found that ResNet-18 is the fastest model for training and ResNet-101 is the slowest. The next research that can be developed is to compare ResNet with Xception, Inception, MobileNet and DenseNet etc.

References

  1. Ö. Karadaǧ and S. Aktaş, “Optimal sample size determination for the ANOVA designs,” Int. J. Appl. Math. Stat., vol. 25, no. 1, pp. 127–134, 2012.
  2. A. Wibisono, J. Rachmad, and E. Anderson, “Deep Learning and Classic Machine Learning Approach for Automatic Bone Age Assessment,” 2019 4th Asia-Pacific Conf. Intell. Robot Syst., pp. 235–240, 2019.
  3. C. Rujichan, “Bacteria Classification using Image Processing and Deep Convolutional Neural Network,” 2019.
  4. I. W. S. E. P, A. Y. Wijaya, and R. Soelaiman, “Klasifikasi Citra Menggunakan Convolutional Neural Network ( Cnn ) pada Caltech 101,” vol. 5, no. 1, 2016.
  5. A. Khan, A. Sohail, U. Zahoora, and A. S. Qureshi, “A Survey of the Recent Architectures of Deep Convolutional Neural Networks 1 Introduction,” pp. 1–70.
  6. D. Joshi, “Approaching Bio Cellular Classification for Malaria Infected Cells Using Machine Learning and then Deep Learning to compare & analyze K-Nearest Neighbours and Deep CNNs,” 2017.
  7. S. B. Griesemer and G. Van Slyke, “Assessment of Sample Pooling for Clinical SARS-CoV-2 Testing,” no. January, 2021.
  8. A. Kour, “A Review on Image Processing,” vol. 4, no. 1, pp. 270–275, 2013.
  9. B. Zieli, A. Plichta, K. Misztal, P. Spurek, M. Brzychczy-włoch, and D. Ocho, “Deep learning approach to bacterial colony classification,” 2017.
  10. B. A. Mohamed and H. M. Afify, “Automated classification of Bacterial Images extracted from Digital Microscope via Bag of Words Model,” no. 1, pp. 1–4.
  11. I. Transactions and O. N. Systems, “Efficient and Rapid Machine Learning Algorithms for Big Data and Dynamic Varying Systems,” pp. 1–2, 2017.
  12. A. Buslaev, V. I. Iglovikov, E. Khvedchenya, A. Parinov, M. Druzhinin, and A. A. Kalinin, “Albumentations: Fast and flexible image augmentations,” Inf., vol. 11, no. 2, 2020, doi: 10.3390/info11020125.
  13. S. R. G. B. Grayscale, “Perbaikan Hasil Segmentasi Hsv Pada Citra Digital Menggunakan Metode Segmentasi Rgb Grayscale,” Edu Komputika J., vol. 6, no. 1, pp. 32–37, 2019, doi: 10.15294/edukomputika.v6i1.23025.
  14. F. Ramzan et al., “A Deep Learning Approach for Automated Diagnosis and Multi-Class Classification of Alzheimer’s Disease Stages Using Resting-State fMRI and Residual Neural Networks,” J. Med. Syst., vol. 44, no. 2, 2020, doi: 10.1007/s10916-019-1475-2.
  15. S. B. Kotsiantis, I. D. Zaharakis, and P. E. Pintelas, “Machine learning: A review of classification and combining techniques,” Artif. Intell. Rev., vol. 26, no. 3, pp. 159–190, 2006, doi: 10.1007/s10462-007-9052-3.
  16. J. Feys, “Nonparametric Tests for the Interaction in Two-way Factorial Designs Using R,” vol. 8, no. 2008, pp. 367–378, 2016.
  17. A. Calle-Saldarriaga, H. Laniado, and F. Zuluaga, “Homogeneity Test for Functional Data based on Data-Depth Plots,” pp. 1–25, 2020.

Diposting Oleh:

Yasmin SEVIMA

Tags:

opini

Mengenal SEVIMA

SEVIMA merupakan perusahaan Edutech (education technology) yang telah berkomitmen sejak tahun 2004 dalam menyelesaikan kendala kerumitan administrasi akademik di pendidikan tinggi (Universitas, Sekolah Tinggi, Institut, Politeknik, Akademi, dll.) dengan 99% keberhasilan implementasi melalui SEVIMA Platform, segera jadwalkan konsultasi di: Kontak Kami

Video Terbaru

Bagaimana Kampus Menyusun Kurikulum OBE? — Highlight Workshop SEVIMA di Solo

Mari Diskusi