Comments (4)
yes there is, you can look at the following function and find out your two image distance with print
diff = embs.unsqueeze(-1) - target_embs.transpose(1, 0).unsqueeze(0)
dist = torch.sum(torch.pow(diff, 2), dim=1)
print(dist) # it returns the distance between new face with all faces in your bank
it's in facelib/InsightFace/models/Learner.py
or you can write your own function in Learner Class
like the following
def compare2faces(self, conf, faces, tta=False)
"""faces : list of PIL Image (your faces for comparing) """
faces = faces_preprocessing(faces, conf.device)
if tta:
faces_emb = self.model(faces)
hflip_emb = self.model(faces.flip(-1)) # image horizontal flip
embs = l2_norm((faces_emb + hflip_emb)/2) # take mean
else:
embs = self.model(faces)
diff = embs[0] - embs[1]
dist = torch.sum(torch.pow(diff, 2), dim=1)
return dist
and run it like this:
from facelib import FaceRecognizer, get_config
recognizer = FaceRecognizer(get_config())
recognizer.model.eval()
img1 = PIL.Image.open('')
img2 = PIL.Image.open('')
recognizer.compare2faces(self.conf, faces=[img1, img2], tta=self.tta)
from facelib.
and you can also see the embeddings at (embs
in the infer
function)
if you add any new features to this project let me know
from facelib.
sure I will let you know, Thank you
from facelib.
I tried to run this code but i got this error :
from facelib.
Related Issues (20)
- CPU error HOT 1
- Face Landmarks HOT 1
- Metrics HOT 2
- ShuffleneTiny model for Age-Gender estimation HOT 2
- Nocorrect box coordinates HOT 1
- FaceLib on Nvidia Jetson Nano HOT 2
- Missing dependencies HOT 1
- pred = torch.argmax(input[:, :2], dim=1) HOT 7
- RuntimeError: number of dims don't match in permute HOT 3
- Error in compare two faces HOT 1
- Coordinates for cv2.rectangle() need to be casted to int. HOT 1
- TypeError: infer() got multiple values for argument 'tta' HOT 3
- Error from AgeGender Webcam
- the training dataset of Facial Expression Recognition HOT 1
- OpenCV gives an error after a few seconds of opening the window HOT 1
- some questions HOT 6
- Issue with EasyDict HOT 2
- Expected emotions to detect
- Error in insightface HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facelib.