This repository contains a study on Metric Learning and Siamese Networks, with a small application to put the learned concepts into practice.
- Metric Learning - Study and Application
- Repository Structure
- Setup Instructions
- How to Use
- Objective
- Challenges
- Pre-trained Model
model_training/: Contains the Jupyter notebook for studying and training the model.app/: Simple desktop application to compare images using the trained model.
-
Create a virtual environment in the
appfolder:cd app python -m venv .venv .\.venv\Scripts\Activate.ps1 # Windows source .venv/bin/activate # Linux/macOS
-
Install dependencies:
pip install -r requirements.txt
-
Ensure the Keras model is saved:
- The trained model should be located in
app/model/embedding_network.keras. - If the model is not available, run the
Metric_learning.ipynbnotebook in themodel_training/folder to train and save the model.
- The trained model should be located in
- To explore the study, open the
Metric_learning.ipynbnotebook. - To use the application, run
app/main.py.
The objective of this project is to understand the concepts of Metric Learning and Similarity Learning using Siamese Networks.
During the development of this project, I faced the following challenges:
- Scoring Metrics: Achieving a satisfactory scoring metric for the model was difficult. This led me to study more about metrics and neural network architectures.
- Output Usage: Understanding how to use the model outputs was challenging. I opted to use the distance between embeddings for the loss calculation, but there is still room for improvement.
- Inconsistent Results: The model results were not as good as expected, motivating me to investigate possible errors and optimizations.
- Graphical Visualizations: I struggled to create graphical visualizations that helped understand the model's successes and failures.
These challenges were important for my learning and helped me identify areas for improvement in future projects.
To facilitate the use of the project, I have made a pre-trained model available based on the Metric_learning.ipynb notebook. You can download it using the link below:
Make sure to save the model in the app/model/ folder with the name embedding_network.keras so that the application can use it correctly.