PROJECT_REPORT_FINAL (3)
PROJECT_REPORT_FINAL (3)
SIAMESE NETWORK
A PROJECT REPORT
Submitted by
RAJA MARIAPPAN T
(2023178056)
in partial fulfillment
for the award of the degree
of
APRIL 2025
ii
ANNA UNIVERSITY
CHENNAI - 600 025
BONAFIDE CERTIFICATE
COUNTERSIGNED
Dr.S. SWAMYNATHAN
HEAD OF THE DEPARTMENT
DEPARTMENT OF INFORMATION SCIENCE AND TECHNOLOGY
COLLEGE OF ENGINEERING, GUINDY
ANNA UNIVERSITY
CHENNAI 600025
iii
ABSTRACT
ACKNOWLEDGEMENT
I also thank the faculty member and non teaching staff members
of the Department of Information Science and Technology, Anna University,
Chennai for their valuable support throughout the course of our project work.
RAJA MARIAPPAN T
(2023178056)
v
TABLE OF CONTENTS
ABSTRACT iii
ACKNOWLEDGEMENT iv
LIST OF FIGURES viii
LIST OF TABLES ix
1 INTRODUCTION 1
1.1 DEFECT DETECTION IN MANUFACTURING 1
1.1.1 Visual Inspection Systems 1
1.1.2 Siamese Networks in Defect Detection 2
1.2 CHALLENGES IN DEFECT DETECTION 3
1.2.1 Variability in Defect Appearance 3
1.2.2 Real-Time Processing Requirements 3
1.2.3 Limited Training Data 3
1.2.4 Environmental Factors 4
1.2.5 Cost and Integration 4
1.3 MOTIVATION 5
1.3.1 Quality Assurance 5
1.3.2 Cost Reduction 5
1.3.3 Production Efficiency 5
1.3.4 Adaptability to New Products 5
1.4 OBJECTIVES 6
1.5 CHALLENGES 7
1.6 PROPOSED SOLUTION 7
1.7 TESTING AND EVALUATION 8
1.8 ORGANIZATION OF THE REPORT 8
2 LITERATURE SURVEY 10
2.1 SIAMESE NETWORKS FOR DEFECT DETECTION 10
2.1.1 Basic Architecture and Working Principles 10
2.1.2 Twin and Triple Siamese Networks 11
2.2 OPTIMIZATION TECHNIQUES FOR SIAMESE
NETWORKS 12
2.2.1 Parameter Reduction and Feature Enhancement 12
2.2.2 Loss Functions and Distance Metrics 12
vi
3 SYSTEM DESIGN 17
3.1 SYSTEM ARCHITECTURE 18
3.1.1 Data Acquisition 18
3.1.2 Data Preprocessing 19
3.1.3 Siamese Network Model 19
3.1.4 Training Process 20
3.1.5 Evaluation Method 21
4 IMPLEMENTATION 22
4.1 SETTING UP THE ENVIRONMENT 22
4.1.1 Development Environment Configuration 22
4.1.2 Data Loading and Preprocessing 23
4.1.3 API Setup for Integration 23
4.2 SIAMESE NETWORK ARCHITECTURE 24
4.3 Network Architecture Implementation 25
4.4 TRAINING PROCEDURE 28
4.5 DEFECT DETECTION AND QUANTIFICATION 30
4.6 WEB API FOR INTEGRATION 33
REFERENCES 43
viii
LIST OF FIGURES
LIST OF TABLES
CHAPTER 1
INTRODUCTION
1.3 MOTIVATION
The motivation for this research stems from the potential benefits that
advanced defect detection systems can bring to manufacturing industries:
1.4 OBJECTIVES
1.5 CHALLENGES
CHAPTER 2
LITERATURE SURVEY
0.0157 and Root Mean Square Error (RMSE) of 0.48408. This performance was
comparable to CNN’s 99.31% accuracy but with significantly reduced execution
time—26.29 minutes for the Siamese network versus 44.02 minutes for CNN.
2.5 SUMMARY
CHAPTER 3
SYSTEM DESIGN
CHAPTER 4
IMPLEMENTATION
• PyTorch (1.12.0) for building and training the neural network models
• Flask (2.2.2) for creating a RESTful API to integrate the model into
production systems
defect detection that accepts a reference image (defect-free sample) and one
or more test images. It returns detailed information about each test image,
including a similarity score, defect prediction, and defect percentage. The API
implementation includes:
Input
Assumptions
• The model should generalize across different types of defects within the
same product category
Algorithm
Time Complexity:
Space Complexity: The space complexity is O(b · d), where b is the batch size
and d is the dimension of the feature vectors
26
Expected Output
This module details the training procedure for the Siamese network,
including data preparation, loss function selection, and optimization strategies.
The model was trained on multiple product categories simultaneously to
improve generalization and reduce the need for product-specific models.
Input
• Training dataset containing pairs of images (reference and test) with binary
labels
Assumptions
Algorithm
Time Complexity:
Space Complexity: The space complexity is O(m + b · d), where m is the model
size, b is the batch size, and d is the dimension of the processed data.
30
Implementation Details
Expected Output
Input
Assumptions
Algorithm
Time Complexity:
Process
Expected Output
Input
Assumptions
Algorithm
Time Complexity: Per Request: O(t · m), where t is the number of test images
and m is the complexity of model inference
Space Complexity: O(t · s), where t is the number of test images and s is the
average size of an image
35
Implementation Details
Expected Output
• JSON response containing defect detection results for each test image
CHAPTER 5
Figure 5.1: Training loss convergence over 50 epochs for the combined
dataset.
37
The web interface developed for the defect detection system provides
an intuitive and accessible means for quality control personnel to interact with
the Siamese network model. Figure 5.2 shows the main interface for uploading
reference and test images.
39
Figure 5.2: Web interface for defect detection showing reference image, test
image, and detection results.
The web interface for the defect detection system was implemented
using React.js (v18.2.0) to provide a responsive and interactive user experience.
The architecture follows a component-based design pattern with state
management handled through React Hooks.
40
5.4.2 Limitations
CHAPTER 6
[1] Zihan Zhang, Jing Gao, Feng Xu, and Junjie Chen. ”Siamese GC Capsule
Networks for Small Sample Cow Face Recognition”. IEEE Access,
11:125918–125926, November 2023.
[2] Taj Mohammad, Rajesh Boughey, and Ritu Prasad. ”Implementation
of Siamese Network for Similarity Computation and Prediction of
Handwritten Digits”. International Conference on Current Development
in Engineering and Technology (ICCET), pages 125–132, December 2022.
[3] Debapriya Banerjee, Maria Kyrarini, and Won Hwa Kim. ”Image-Label
Recovery on Fashion Data Using Image Similarity from Triple Siamese
Network”. Technologies, 9(1):1–16, January 2021.
[4] Marco Fisichella. ”SimPair LSH: A Novel Locality-Sensitive Hashing
for Faster Similarity Learning”. arXiv preprint arXiv:2101.12345, pages
1–18, January 2021.
[5] Arif Rahman and Team. ”Category-Aware Siamese CNN for Image
Similarity Learning”. International Journal of Machine Learning and
Cybernetics, 11(4):791–804, April 2020.
[6] Huafeng Liu and Others. ”Road Region Recognition Using SiNN with
LiDAR and Camera Fusion”. Sensors, 20(7):2037, March 2020.
[7] Bo Tao and Others. ”Probabilistic Siamese Network for Image Matching”.
Pattern Recognition Letters, 125:534–540, October 2019.
[8] Le Yang and Others. ”Remote Sensing Image Change Detection Using
Siamese Network”. IEEE Transactions on Geoscience and Remote
Sensing, 56(6):3295–3305, June 2018.
[9] Jake Snell, Kevin Swersky, and Richard Zemel. ”Prototypical Networks
for Few-Shot Learning”. Neural Information Processing Systems
(NeurIPS), 30:4077–4087, December 2017.
[10] Iaroslav Melekhov, Juho Kannala, and Esa Rahtu. ”Siamese Network
for Object Similarity Estimation”. International Conference on Pattern
Recognition (ICPR), pages 378–383, December 2016.