SthPhoenix / InsightFace-REST

InsightFace REST API for easy deployment of face recognition services with TensorRT in Docker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Giving multiple detected faces at once to recognition model

wareziom opened this issue · comments

hi. I am able to detect faces in an image with scrfd. If there is more than one face in the image, I have to give the faces one by one to the Recognition model, respectively.
How can I do this in such a way that I get all the faces in one go (at once ) and get the features in less time?

bboxes, kpss = self.det_model.detect(img,
                                             max_num=max_num,
                                             metric='default')
        if bboxes.shape[0] == 0:
            return []
        ret = []
        for i in range(bboxes.shape[0]):
            
            bbox = bboxes[i, 0:4]
            det_score = bboxes[i, 4]
            kps = None
            if kpss is not None:
                kps = kpss[i]
            face = Face(bbox=bbox, kps=kps, det_score=det_score)

            for taskname, model in self.models.items():

                if taskname=='detection':
                    continue
                model.get(img, face)
            ret.append(face)
            
        
        return ret

get feature :

def get_feat(self, imgs):
        if not isinstance(imgs, list):
            imgs = [imgs]
 
        input_size = self.input_size
        
        blob = cv2.dnn.blobFromImages(imgs, 1.0 / self.input_std, input_size,
                                      (self.input_mean, self.input_mean, self.input_mean), swapRB=True)
   
        net_out = self.session.run(self.output_names, {self.input_name: blob})[0]
   
        return net_out

Once again, this question seems to be related to official insightface package.

In this repo batch processing is supported out of the box.

I do not know where this question really should be asked if this is not the right place.
I saw that you answered another person about the same question, but I did not fully understand.
I think this question has been asked exactly the right place and it can be a question of many people and you refuse to answer this question and I do not understand.

Code snippets you shown above belongs to official deepinsight/insightface repository, so it's better to address questions related to their code to their repository.

Also, as I have said before, in my repository batch processing is already implemented (currently for TensorRT) You can check face_model.py as starting point.

thank you so much for your help.

Closing as solved