Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

cosine_distance in face_recognition_demo

anuragrawal
Beginner
1,157 Views

Hi,

 

Can someone explain to me the significance of multiplying by .5 in the cosine_distance() method here? : https://github.com/openvinotoolkit/open_model_zoo/blob/64fe6ef5c8ee769a97ed4d884ec3fbb8b6ca6477/demos/face_recognition_demo/python/faces_database.py#L38

 

I don't think it's accurate.

 

Thanks!

Anurag

0 Kudos
6 Replies
Aznie_Intel
Moderator
1,123 Views

 

Hi Anuargrawal,

 

Thanks for reaching out.

 We are checking this with our development team and will get back to you soon.

 

 

Regards,

Aznie


0 Kudos
anuragrawal
Beginner
1,087 Views

@Aznie_Intel Do you have an update for me? Thanks!

0 Kudos
Aznie_Intel
Moderator
1,021 Views

Hi Anuargrawal,

 

We are checking this with our developer team, which may take some time. We will update you with the information once available.

 


Regards,

Aznie


0 Kudos
anuragrawal
Beginner
802 Views

@Aznie_Intel, When can I expect an update on this?

0 Kudos
Aznie_Intel
Moderator
764 Views

Hi Anuragrawal,

 

Thanks for your patience. Here is the information from our developer team regarding the cosine value:

 

Multiplying by 0.5 is a part of the normalization process to scale the cosine distance value to a specific range. Typically, the cosine similarity ranges from -1 to 1, where 1 means identical vectors and -1 means completely opposite. By adding 1 and then multiplying by 0.5, the range is transformed to 0 to 1.

 

Without the multiplication by 0.5, the cosine similarity values will range from -1 to 1 (after adding 1 to the original cosine similarity). This means that a value of -1 indicates completely dissimilar vectors, a value of 0 indicates orthogonality (i.e., the vectors are unrelated), and a value of 1 indicates identical vectors. By multiplying by 0.5, the range is transformed to 0 to 1, which can be easier to interpret: a value closer to 0 indicates greater similarity, and a value closer to 1 indicates greater dissimilarity.

 

So, while you can certainly compute cosine similarity without the multiplication step, the interpretation of the results will be different. The choice to include this step often depends on the specific requirements of ones application and how you want to interpret the results.

 

I hope this is helpful to you.

 


Regards,

Aznie


0 Kudos
Aznie_Intel
Moderator
617 Views

Hi Anuragrawal,


This thread will no longer be monitored since we have provided information. If you need any additional information from Intel, please submit a new question.



Regards,

Aznie


0 Kudos
Reply