pcr-upm / opal23_headpose

Headpose estimation using OPAL (2023)
MIT License
44 stars 4 forks source link

Inference on own data #5

Closed HeChengHui closed 5 months ago

HeChengHui commented 5 months ago

Thank you for your work. I would like to ask how to use this on my own videos/images?

bobetocalo commented 5 months ago

Run https://github.com/pcr-upm/opal23_headpose/blob/main/test/opal23_headpose_test.py using your own image/video. For example, by replacing the example.tif file name.

bobetocalo commented 5 months ago

You should follow the dockerfile steps in order to run:

python images_framework/alignment/opal23_headpose/test/opal23_headpose_test.py --input-data images_framework/alignment/opal23_headpose/test/example.tif --database 300wlp --gpu 0 --rotation-mode euler --save-image
HeChengHui commented 5 months ago

i would like to use it with my own face detector. Is the below process function for Opal23HeadPose correct to get the euler angles in degree? image refers to the whole frame.

def process(self, image, face_bbx):
        """
        pass in a frame and do the headpose estimation
        """        
        warped_image = self.preprocess(image, face_bbx)

        # Image array (H x W x C) to tensor (1 x C x H x W)
        tensor_image = torch.tensor(warped_image, dtype=torch.float)
        tensor_image = tensor_image.permute(2, 0, 1) / 255
        tensor_image = tensor_image.unsqueeze(0).to(self.device)

        with torch.set_grad_enabled(False):
            out = self.model(tensor_image)[0].detach().cpu().numpy()
            yaw, pitch, roll = out
GKG1312 commented 1 month ago

Hi @bobetocalo How are we selecting database here? For my custom data I am not sure in which dataset it have more resemblance, In such case which database I need to use or if I can define custom database class, what are the things I need to define and pass?