Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions faceboxes_pytorch/faceboxes_face_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ def load_model(self, model, pretrained_path, load_to_cpu):
def get_faceboxes(self, image, threshold=0.2):
resize = 1

img = np.float32(image)
im_height, im_width, _ = img.shape
scale = torch.Tensor([img.shape[1], img.shape[0], img.shape[1], img.shape[0]])
img -= (104, 117, 123)
img = img.transpose(2, 0, 1)
img = torch.from_numpy(img).unsqueeze(0)
im_height, im_width, _ = image.shape
scale = torch.Tensor([im_width, im_height, im_width, im_height])

img = torch.from_numpy(image).unsqueeze(0)
img = img.to(self.device)
img = img.to(torch.float32)
scale = scale.to(self.device)

img = torch.sub(img, torch.tensor((104,117,123)).to(self.device))
img = img.permute(0,3,1,2)

loc, conf = self.net(img) # forward pass
priorbox = PriorBox(cfg, image_size=(im_height, im_width))
priors = priorbox.forward()
Expand Down