Professional Documents
Culture Documents
Manuscript-05 15 19
Manuscript-05 15 19
A Thesis Manuscript
Presented to the Faculty of the
Department of Computer Science and Technology
College of Engineering
Visayas State University
Visca, Baybay City, Leyte
LIST OF TABLES
Abstract
This study
Keywords:
2
CHAPTER I
INTRODUCTION
Aba
Abaca fiber is considered as one of the strongest among natural fibers, which
is three times the lack of instruments for an objective measurement of fiber quality,
In a study by Sinon (2013), the grade of the abaca fiber image in the bundle
was predicted by
The study by Sinon (2013) did not determine the grade of the abaca fiber
Tobias et. al. (2018) stated that CNN has achieved human-like performance in several
inspection. Hence, the lack of instrument in grading abaca fiber makes the manual
process not reliable, subjective, time-consuming and costly. In a previous study, abaca
fiber grade classifier system made by (Sinon, 2013) is only based on color using
abaca fiber colorimeter. This new study will find a new method in grading abaca fiber
by acquiring its raw input pixel values and the learnable filters will be applied.
The study aims to develop an Abaca Fiber Grade Classification System that
can recognize the grade of abaca fiber based on its color and texture from a digital
image.
architecture to be applied in the system as the classifier for the abaca fiber
grade bundle;
2. Make a photo box used for image acquisition of the bundled abaca fiber;
3. Design and develop an easy to use graphical user interface for the abaca fiber
4. Evaluate the performance of the classifier using accuracy and Cohen's kappa
statistic.
measurement in the automation of abaca fiber bundle grading. The automated abaca
4
fiber grade classifier system would aid both the abaca producers and traders to fairly
This study covers from counting of colonies in a petri dish that are circular in
shape, separation
The sample data gathered were from Ching bee Trading Corporation at Brgy.
Hilapnitan, Baybay City, Leyte. Images were taken in dark room at Brgy. Patag,
Baybay City, Leyte. The development and testing of the system were conducted at the
CHAPTER II
(CNN) is a
based and CNN supervised learning methods. He mentioned that traditional feature-
Convolutional Layer
This layer has two mechanisms that perform element-wise multiplication and
add up to bias:
Activation function
After convolutional
Pooling Layer
The most important information. Rosebrock, (2017) stated that this layer
operates in two
6
In this layer
Zisserman & Simonyan (2015) are the creators of the VGGNet-16 architecture
In image classif
Moreover, in a recent study by Cusano et al., (2016) they ensembled the hand-
crafted image
In a study by (Sinon, 2013) the grade of the abaca fiber image in bundle was
predicted by two
7
CHAPTER III
The abaca fiber samples (see Appendix A for the images) were obtained
through a letter request to the Ching bee Trading Corporation (see Appendix C.A) and
the actual grading of abaca fiber sample was done by Mr. Ariel C. Cinco (see Appendix
C.B). Twenty sample images of abaca fiber for each of the seven abaca fiber grades
were segregated for image acquisition. The ten sample images of each grade were used
for training and testing phase. A 16.0-megapixel phone camera Samsung S6 was used
to capture the abaca fiber images. And a photo box was created in acquiring abaca fiber
Shown in Fig. 5 below is the system architecture of the study. The abaca fiber
grade classifier
8
Image Acquisition
The different viewpoint and illumination of the acquired digital image will
a. b.
Figure 6. a. Location and b. Set-up in acquiring abaca fiber images
10
Training Phase:
The
Convolutional Layer
Convolution layer are set of parallel feature maps shown in Fig.8, formed after
sliding different
M −1 N −1 C
F=( I∗K )ij = ∑ ∑ ∑ Ii +m , j+n , c∗K p=cm,, q=0
n
+b i, j Eq. 1
m =0 n=0 c=0
Where:
j = jth
i,j
b = bias parameter
p,q
C =σ ¿ Eq. 2
m,n
Where:
M&N=
p ,q
b
Dim c
12
Where:
Figure 8. Left: learnable K kernels. Middle: Image. Right: After convolution the output,
called feature map.
The weighted
Pooling Layer
The mechanism
13
l−1 p ,q
a i =f (P ) Eqn. 7
Where:
Forward Propagation. All random weights values are set during this mechanism
and bias values is set 1 to make it the classification layer using in fully connected layers
that produces an estimate of the probability for each abaca grades as shown in Eqn. 12.
n
z =∑ wlij al−1
l
j
l
j +b j Eqn.8.1
i=1
l l
a j=σ (z j ) Eqn.8.2
Where:
14
l T
a =σ ( ( W ) a
l l−1 l
+b ) Eqn. 9
Where:
a =σ ( ( W ) a + b )
L L L−1TL
Eqn. 10
Where:
L=
Where:
Backward Propagation. After forward run, the output to the weights adjust from
its initial random value of weights and biases. During the update, the loss function of
final layer with respect to the parameters is computed first where the gradient of first
convolutional layer is computed last. And then, this process used a partial derivative of
15
one layer being reused in computation of partial derivative of another layers using chain
rule. In effect the loss function will decrease and the performance of the model increases.
This algorithm called backpropagation by updating its parameters to its best in order to
minimize the loss function. The nomenclature of every equation shown below:
α = learning rate
L+ 1
ŷ i = predicted output value
Loss function formula of ith neuron as the classification layer (L+1) with respect to the
∂ L ( ŷ L+1 , yi ) 1
i−n
yi 1− y i
= ∑ L+1
i
+ Eqn.14
∂ yi
L+1
n 1 ŷi L+1
1− ŷ i
Loss function formula with respect to weight w Li ,i−1 of ith neuron in the final layer L:
16
∂ L ( ŷ L+1 , yi ) 1
n
− y i 1− y i
i
∂ wiL,i−1
= ∑ ( L+ 1 +
n i=1 ŷ i 1− ŷ L+1
¿ )¿ ¿ Eqn.15
i
Loss function formula with respect to weights of every neuron in Lth layer:
[ ]
∂ L ( ŷ1 , y1 )
L+1
L
∂ L( ŷi
L+1
, y) ∂ w 1 ,i−1
L
= ⋮ =¿ Eqn.16
∂W
∂L(ŷ )
L+1
i ,y
i
L
∂w i ,i−1
Loss function formula with respect to bias b li in ith neuron in Lth layer:
∂ L ( ŷ L+1 , yi ) 1
n
∂ L ( ŷ iL+1 , y i ) ∂ ŷ iL+1
= ∑ =σ ( z L+1
i − yi )
i
Eqn.17
∂ bLi n i=1 ∂ ŷi L+1
∂ bi L
Loss function formula with respect to bias of every neurons at Lth layer:
[ ]
∂ L ( ŷ1 , y1 )
L+1
[ ]
σ ( z 1 ¿− y 1)
L L+1
∂ L( ŷi
L+1
, y) ∂b 1
L
= ⋮ = ⋮ Eqn.18
∂b
∂L(ŷ , yi ) σ (z ¿− y i)
L+1 L+ 1
i i
L
∂b i
Loss function formula with respect to weight of ith neuron at first layer l in fully
connected layer:
∂ L ( ŷ L+1
i , yi ) ∂ L ( ŷ iL+ 1 , y i ) ∂ ŷ L+1
i
l
y i−z i
= = Eqn.19
z i ( 1−z i )
l L+1 l l l
∂ wi ,i−1 ∂ ŷi ∂ w i ,i−1
17
Then, the loss function formula with respect to weight of all neuron at lth layer shown
below,
[ ][ ]
l
∂ L ( ŷ1 , y1 )
L+1
y1 −z1
z 1 ( 1−z 1 )
l l l
∂ L( ŷi
L+1
, y) ∂ w1 , o
l
= ⋮ = ⋮ Eqn.20
∂W l
∂L(ŷ )
L+1
i ,y
i
y i −z i
z ( 1−z i )
l l l
∂w i ,i−1 i
Loss function formula with respect to bias of ith neuron at lth layer l in fully connected
∂ L ( ŷ L+1
i , yi ) ∂ L ( ŷ iL+ 1 , y i ) ∂ ŷ L+1
i
l
= L+1 l
=z l−1
i − y i Eqn.21
∂b i ∂ŷ i ∂b i
Then, the loss function formula with respect to bias at the layer l shown below,
[ ]
∂ L ( ŷ1 , y1 )
L+1
[ ]
∂ L( ŷi
L+1
, y) ∂ b1
l
z l−1
1 − y1
l
= ⋮ = ⋮ Eqn.22
∂b l−1
∂L(ŷ , yi ) − yi
L+1
i
z i
l
∂b i
and bias values in convolutional layers. But from the first layer in the fully connected
layer, the single long vectors from the pooled feature maps must be updated first. Below
∂ L ( ŷ L+1
n , yn ) ∂ L ( ŷ nL+1 , y n ) ∂ y nL+1
= Eqn.23
∂ ali ∂ y L+1
n ∂ al−1
i
18
After the single long vector updated, the reshaping of the long vector take place in
the pooling layer in Eqn. 24. Then, there are no parameters to be updated in this layer so
∂ L ( ŷn , yn)
L+1
p, q −1
P =f ( l
) Eqn. 24
∂ ai
∂ L ( ŷ L+1
i , yt )
p, q
=P p , q Eqn. 25
∂C m ,n
Then, the loss function formula with respect to the convolutional learnable filter
p ,q
k u ,v can be computed as shown in Eqn.26. Then, updated values of learnable filter k p ,q in
Eqn. 27.
∂ L ( ŷ L+1 , yi ) M −1 N−1
∂ L ( ŷ iL+1 , y n )
=∑ ∑
i
X m−u , n−v Eqn. 26
∂ k up,, vq m=0 n ∂C mp ,, qn
p ,q
°∗∂ L ( ŷ iL+1 , y n )
k =rot 180 Eqn. 27
∂ Cmp ,, qn
Finally, the loss function formula with respect to the bias b p ,q of the convolutional
∂ L ( ŷi , yi ) ∂ L( ŷi , yn )
L+ 1 M −1 N −1 L+1
b p ,q
= p ,q
=∑ ∑ p ,q
Eqn.28
∂b m=0 n ∂C m ,n
19
In this part, the optimization techniques are developed for the model in order to
minimize the loss function in every update of the learning parameters such as WL+1, bL+1,
WL, bl, kp,q and bp,q at each iteration process on the basis of gradient descent. One of this is
the stochastic gradient descent optimization. The weight and bias update of fully
L+1 L+1
∂ L ( ŷ iL+1 , y )
W =W −α L
Eqn. 29.a
∂W
L+1 L+1
∂ L ( ŷ iL+1 , y )
b =b −α Eqn. 29.b
∂ bL
Where:
∂ L ( ŷ L+1
i , y)
L
= shown in Eqn.16
∂W
∂ L ( ŷ L+1
i , y)
= shown in Eqn.18
∂ bL
Then, the weight and bias update of fully connected layer in first layer l in Eqn.
l l
∂ L ( ŷ iL+1 , y )
W =W −α Eqn. 30.a
∂Wl
l l
∂ L ( ŷ L+1
i , y)
b =b −α Eqn. 30.b
∂ bl
20
Where:
∂ L( ŷi , y)
L+1
l
= shown in Eqn. 20
∂W
∂ L ( ŷ L+1
i , y)
= shown in Eqn. 22
∂ bl
Finally, the weight/pixel values and bias update of learnable filter in Eqn. 31.a &
31.b.
p ,q p, q
∂ L ( ŷ L+1
i , y)
k =k −α Eqn. 31.a
∂ k up,, vq
p .q
∂ L ( ŷ iL+1 , y )
b =α Eqn. 31.b
∂ k up,,qv
Where:
∂ L ( ŷ L+1
i , y)
= shown in Eqn. 26
∂ k up,v,q
∂ L ( ŷ L+1
i , y)
= shown in Eqn. 28
∂ k up,v,q
Importantly, a reminder for the overfitting when too many parameters of the
model can cause by having too few samples to learn in training process. Then, the
mechanism is to generate more training data from existing sample images, “augmenting”
randomly “dropping out” (i.e. setting the value to zeroed out if the value is less than or
equal to the initialize probability value). Then, the output values of a particular layer
subtracting the mean from the data and then giving the unit standard deviation by
dividing the data by its standard deviation. In result, the data follows a normal
distribution in which centered and scaled to unit variance. The advantage of this
technique is effective at reducing the number of epochs and large variety of learning rates
in every parameter in the network. But the drawback of this technique is the
computational time.
Implementation
The programming language used in this study was Python version 3.6 under
python deep learning library in python was used whose backend is Tensorflow API.
Additionally, Qt designer was used for the graphical user interface (GUI) and some
packages of python installed such as pyqt5, sklearn, imutils, matplotlib, numpy, pickle,
22
opencv, random, os and many more. Then, in evaluating the performance of the system
Figure 10. Use Case Diagram of the Abaca Fiber Classifier System
The generated model and label files after several experiments will be subject for
testing in which uses a feed forward propagation. Ten sample abaca fibers per grade were
used as testing data to determine the performance of the system using kohen kappa
statistic and accuracy.by gathering the predicted output of the system and actual abaca
fiber grade based on the grading of PhilFIDA Inspector Mr. Ariel Cinco.
1. Total False Prediction (TFP) – total false prediction in each grade of abaca
2. Total True Prediction (TTP) - total true prediction in each grade of abaca fiber
Actual Abaca Fiber Grade based on PhilFIDA Inspector Mr. Ariel Cinco Total
Actual: S2 Actual: S3 Actual: I Actual: G Actual: H Actual: JK Actual: M1
Predicted: S2 (TTP) (TFP) (TFP) (TFP) (TFP) (TFP) (TFP) P:S2total
System Predicted: S3 (TFP) (TTP) (TFP) (TFP) (TFP) (TFP) (TFP) P:S3total
Predicted Predicted: I (TFP) (TFP) (TTP) (TFP) (TFP) (TFP) (TFP) P:Itotal
Grade Predicted: G (TFP) (TFP) (TFP) (TTP) (TFP) (TFP) (TFP) P:Gtotal
Predicted: H (TFP) (TFP) (TFP) (TFP) (TTP) (TFP) (TFP) P:Htotal
Predicted: JK (TFP) (TFP) (TFP) (TFP) (TFP) (TTP) (TFP) P:JKtotal
Predicted: M1 (TFP) (TFP) (TFP) (TFP) (TFP) (TFP) (TTP) P:M1total
Total A:S2total A:S3total A:Itotal A:Gtotal A:Htotal A:JKtotal A:M1total (Grand
Total)
25
1. Cohen’s kappa statistic – measures the precision between prediction of the system
and actual grading of abaca fiber. The kappa statistic value is calculated using
Where:
[( )( )( )(
P : S 2total P :S 3 total P : I total P :Gtotal
i ∗A :S 2total ∗A : S 3total ∗A : I total
Grand Total Grand Total Grand Total Grand Total
∑ Pi +¿ P +i
=
Grand Total
+
Grand Total
+
Grand Total
+
Grand T
i=1
Eqn. 33
Where:
i ∑ Pi +¿P +i
33
Where:
∑ Pi +¿ P +i
¿ is the total proportion of marginal in the confusion matrix
i=1
TTPtotal
accuracy= x 100 Eqn. 34
Grand Total
Where:
CHAPTER IV
which is open source and free must be installed. After installation set-up, virtual
environment must be
Keras is a one
{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "tensorflow",
"image_data_format": "channels_last"
}
After the keras.json file configure, different libraries imported to one python file
only for the sake of simplicity in the throimplementation and to minimize its processing
In the phase of implementation, Qt designer was used for the Graphical User
Interface (GUI) of the system. Then, the generated .ui file of the application is subjected
to conversion into python file using anaconda prompt as shown in Listing 2. The quoted
texts are subject to change. The generated python file for the GUI of the system was
Training Phase
and the implementation is shown in Listing 3. Moreover, GUI design for the training
genModel.add(Activation("relu"))
genModel.add(BatchNormalization(axis=changeDime))
genModel.add(Conv2D(64, (3, 3), padding="same"))
genModel.add(Activation("relu"))
genModel.add(BatchNormalization(axis=changeDime))
genModel.add(MaxPooling2D(pool_size=(2, 2)))
genModel.add(Dropout(0.25))
genModel.add(Flatten())
genModel.add(Dense(1024))
genModel.add(Activation("relu"))
genModel.add(BatchNormalization())
genModel.add(Dense(abacaGrades))
genModel.add(Activation("softmax"))
return genModel
30
prompted in order to locate the training dataset of the acquired images for training phase,
as shown in Fig. 11. After the start training button is triggered the training process begins,
Figure 12. Folder dialog when Load Image File Directory is triggered
If the user clicked the start training button without any file directory for training
After several experiments, the generated good model has training parameters of
learning rate set to 0.001, training epochs set to 100, random seed set to 42 and batch size
set to 32. At epoch 57 in the training process, achieved a minimum loss and then the
model is saved automatically using a poweful method called “callbacks” in Keras API.
Testing Phase
The generated model is tested with 70 images and the results are shown in Table
Table 5. Moreover, the interface design of this phase is shown in Fig. 14 below. Fig. 15
on the other hand shows when an image is loaded and the results of the prediction model.
33
While other feature of the system is to generate a model after the show
model button was click shown in Fig. 16and the detailed image shown in Appendix E.
Fig.17 and 18 shown the feature maps and specific feature map at every layer and Fig. -
Figure 19. Specific feature map of a particular convolutional layer in the model
36
Performance Evaluation
Actual Abaca Fiber Grades based on PhilFIDA Inspector Mr. Ariel Cinco Total
Actual: Actual: Actual: Actual: Actual:
Actual: S3 Actual: I
S2 G H JK M1
Predicted: S2 10 0 0 0 0 0 0 10
System Predicted: S3 0 9 0 0 0 0 0 9
Predicted Predicted: I 0 0 10 2 0 0 0 12
Grades Predicted: G 0 0 0 0 0 0 0 0
Predicted: H 0 0 0 0 10 1 0 11
Predicted: JK 0 0 0 0 0 9 0 9
Predicted:M1 0 1 0 8 0 0 10 10
Total 10 10 10 10 10 10 10 70
CHAPTER V
Summary
Classifying abaca fiber grades done by visual inspection based on its physical
features such as color and texture is difficult even with the aid of the expert. The process
is subjective, not reliable, time-consuming and costly. Thus, this study developed a
software that could be used to objectively augment the human capability in grading the
abaca fiber.
In a previous study, abaca fiber grade classifier system made by (Sinon, 2013) is
only based on color using abaca fiber colorimeter. However, Cusano et al., (2016)
implemented different kinds of image classification methods in raw food texture images
including CNN architectures under different lightning conditions. Results clearly showed
that the VGGNet-16 CNN architecture outperforms other with a high classification
accuracy of 98.21%. They concluded that the datasets taken under no variation in lighting
condition clearly boosts the performance of the different image classification methods.
The Python version 3.6 programming language with the aid of Spyder IDE 3.3.3
within Anaconda Python Distribution was used to develop the system. Specifically, Keras
deep learning library whose computational backend is TensorFlow for saving the trained
model and then pickle library for saving the grade labels of abaca fiber and many more
Inspired by Cusano et al., (2016) paper, this study implements a small version of
VGGNet-16 architecture equipped with CPU Intel core i3 processor because the actual
activation function, three pooling layers and 1024 inputs to fully connected layer and 7
outputs for different grades of abaca fiber. Moreover, a photo box is used for controlling
Conclusion
The abaca fiber grade classifier system using a small version of VGGNet-16 CNN
architecture with the aid of photo box for acquisition set-up produce a result of 83%
classification accuracy and Cohen kappa level of agreement is weak. The developed
system was an effective alternative for the manual identification of abaca fiber grades
Recommendation
Based on the results, further study is recommended to build the high effectiveness
GridSearchCV technique.
42
equip with GPU processors. Then, the image dimension from the acquisition
should not be large enough in order to retain the quality of the image when
LITERATURE CITED
Naik, S., & Patel, B. (2013). Machine Vision based Fruit Classification and Grading - A
Review. International Journal of Computer Applications (p. 13). Uka Tarsadia
University, Bardoli, Surat, Gujarat, India: IEEE.
PhilFIDA. (2016). Abaca fiber: Grading and Classification – Hand-stripped and Spindle/
Machine stripped. Diliman, Quezon City: Philippine National Standard. Bureau of
Agriculture and Fisheries Standards.
PhilFIDA. (2018). Fiber Statistics. Retrieved October 28, 2018, from Philippine Fiber
Industry Development Authority: http://www.philfida.da.gov.ph/index.php/2016-
11-10-03-32-59/2016-11-11-07-56-39
Rosebrock, A. (2017). Deep Learning for Computer Vision with Python. California,
USA: Pyimagesearch.
Sinon, B. (2013). Development of an Abaca Fiber Grade Recognition System using
Neural Networks. Visayas State University (VSU), Baybay City, Leyte:
Undergraduate Thesis (Department of Computer Science and Technology).
TechSciResearch. (2018, October 28). Retrieved from Philippines Abaca Fiber Market
Forecast and Opportunities: https://www.techsciresearch.com/report/philippines-
abaca-fiber-market-forecast-and-opportunities-2019/390.html
Tobias, L., Ducournau, A., Rousseau, F., Mercier, G., & Fablet, R. (2018). Convolutional
Neural Networks for Object Recognition on Mobile Devices: a Case Study. IEEE,
p. 7.
Zisserman, A., & Simonyan, K. (2015). VERY DEEP CONVOLUTIONAL
NETWORKS FOR LARGE-SCALE IMAGE RECOGNITION. ICLR , 14 pages.
45
APPENDICES
46
APPENDIX A
STREAKY THREE(S3)
48
CURRENT (I)
SECONDS (JK)
APPENDIX B
APPENDIX C
LETTER OF REQUEST
56
57
57
58
APPENDIX D
Grade Description
Name Alphanumer Fiber strand Color Stripping Texture
ic code size (in mm)
Mid current EF 0.20 – 0.50 Light ivory to a hue of very light brown to Excellent Soft
very light ochre
Streaky Two S2 0.20 – 0.50 Ivory white, slightly tinged with very light Excellent Soft
brown to red or purple streak
Streaky Three S3 0.20-0.50 Predominant color – light to dark read or Excellent Soft
purple or a shade of dull to dark brown
Current I 0.51-0.99 Very light brown to light brown Good Medium soft
Soft seconds G 0.51-0.99 Dingy white, light green and dull brown Good
58
59
APPENDIX E
59
60
60