Lullooo's picture
project description
ef4d8c2 verified
|
Raw
History Blame Contribute Delete
3 kB
---
title: SiameseCNN ImgMatching
emoji: πŸ“š
colorFrom: green
colorTo: red
sdk: gradio
sdk_version: 6.5.1
app_file: app.py
pinned: false
short_description: πŸ”’ Digit matching & recognition through Siamese CNN
---
# πŸ”’ Siamese CNN: Number Recognition & Similarities
**Note:** See model performances and examples [here πŸ“ˆ](https://github.com/Lulloooo/SiameseNet-NumRecognition/blob/main/Performances-Examples.md)
<br/><br/>
## 🎯 PURPOSES
This project aims to develop a Siamese Neural Network 🧠 able to match and identify different kinds of numerical digits πŸ”’.
The model learns to measure how similar two images are rather than directly classifying them. This makes it suitable for tasks like:
- **🀝 Digits matching and recognition**: Compare the uploaded digits with those in the test set. Once a match is found, label the uploaded digit with the same label as the matched one.
- **πŸ”“ Security unlocking mechanisms**: The camera captures an istant image of a face or an object. If the similarity with those in the training pool is high, it unlocks the device/program.
- **πŸ”Ž Duplicate detection**: Define a similarity score between the external image and those in the reference set. If similarity with one of these is high, it is likely is a duplicate.
<br/><br/>
## πŸ› οΈ WORKFLOW
The workflow is quite straightforward: the user is prompted to upload a picture of a number or to draw it in a canvas, and the Siamese Network returns:
- 1️⃣ Which digit is the uploaded/drawn picture (The uploaded img is a ...) along with its similarity score.
- 2️⃣ 3 matching pics coming from the testing dataset.
<br/><br/>
## ⚠️ WARNINGS
Be fully aware of the model's limitations by reading the [model limitations doc βœ‹](https://github.com/Lulloooo/SiameseNet-NumRecognition/blob/main/Performances-Examples.md)
<br/><br/>
## 🧠 MODEL OVERVIEW
The Siamese architecture leverages shared convolutional layers to extract features from two images, then computes their Euclidean distance in embedding space. A contrastive loss function is employed:
&nbsp;&nbsp;**L = (1 - Y) * (1/2) * D^2 + Y * (1/2) * (max(0, m - D))^2**
with:
- D: distance between embeddings
- Y = 0 for similar and Y = 1 for dissimilar
- m: margin parameters (can be changed)
<br/><br/>
__________________________________________________________________________________________________________
**Note**: I got the idea to implement this kind of network for this kind of task + some code chunks from the [Daily Dose of Data Science](https://www.dailydoseofds.com/) newsletter πŸ“¨. They are really awesome, and everyone interested in data science should check them too πŸ˜‰.
**Note2**: As this was a work-related project, it has been approved for posting, and all sensitive information and data are omitted to protect privacy. Code snippet containing sensitive data has not been posted.
__________________________________________________________________________________________________________