Spaces:
Sleeping
Sleeping
project description
Browse files
README.md
CHANGED
|
@@ -9,5 +9,43 @@ app_file: app.py
|
|
| 9 |
pinned: false
|
| 10 |
short_description: π’ Digit matching & recognition through Siamese CNN
|
| 11 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
pinned: false
|
| 10 |
short_description: π’ Digit matching & recognition through Siamese CNN
|
| 11 |
---
|
| 12 |
+
# π’ Siamese CNN: Number Recognition & Similarities
|
| 13 |
+
π©
|
| 14 |
+
<a href="mailto:lucagabri98@live.it"><img src="https://img.shields.io/badge/lucagabri98-c71610?style=flat&logo=gmail&logoColor=white" width="80"></a>
|
| 15 |
+
<a href="la-databizanalyst"><img src="https://img.shields.io/badge/%40LA-0E76A8?style=flat&logo=linkedin&logoColor=white" width="32"></a>
|
| 16 |
+
π©
|
| 17 |
+
**Note:** See model performances and examples [here π](https://github.com/Lulloooo/SiameseNet-NumRecognition/blob/main/Performances-Examples.md)
|
| 18 |
+
<br/><br/>
|
| 19 |
+
## π― PURPOSES
|
| 20 |
+
This project aims to develop a Siamese Neural Network π§ able to match and identify different kinds of numerical digits π’.
|
| 21 |
+
The model learns to measure how similar two images are rather than directly classifying them. This makes it suitable for tasks like:
|
| 22 |
|
| 23 |
+
- **π€ 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.
|
| 24 |
+
- **π 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.
|
| 25 |
+
- **π 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.
|
| 26 |
+
<br/><br/>
|
| 27 |
+
## π οΈ WORKFLOW
|
| 28 |
+
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:
|
| 29 |
+
- 1οΈβ£ Which digit is the uploaded/drawn picture (The uploaded img is a ...) along with its similarity score.
|
| 30 |
+
- 2οΈβ£ 3 matching pics coming from the testing dataset.
|
| 31 |
+
<br/><br/>
|
| 32 |
+
## β οΈ WARNINGS
|
| 33 |
+
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)
|
| 34 |
+
<br/><br/>
|
| 35 |
+
## π§ MODEL OVERVIEW
|
| 36 |
+
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:
|
| 37 |
+
|
| 38 |
+
**L = (1 - Y) * (1/2) * D^2 + Y * (1/2) * (max(0, m - D))^2**
|
| 39 |
+
|
| 40 |
+
with:
|
| 41 |
+
- D: distance between embeddings
|
| 42 |
+
- Y = 0 for similar and Y = 1 for dissimilar
|
| 43 |
+
- m: margin parameters (can be changed)
|
| 44 |
+
<br/><br/>
|
| 45 |
+
|
| 46 |
+
__________________________________________________________________________________________________________
|
| 47 |
+
**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 π.
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
**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.
|
| 51 |
+
__________________________________________________________________________________________________________
|