From 4541d29a1402fb40d77f3821fff68259c365870a Mon Sep 17 00:00:00 2001 From: yuji nunome Date: Thu, 9 Dec 2021 12:10:28 +0900 Subject: [PATCH] =?UTF-8?q?cpu=E3=81=A7=E5=AE=9F=E6=96=BD=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9Ffloat=E5=A4=89=E6=8F=9B=E3=81=A8subt?= =?UTF-8?q?ract=E3=82=92gpu=E3=81=A7=E5=AE=9F=E6=96=BD=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- faceboxes_pytorch/faceboxes_face_detector.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/faceboxes_pytorch/faceboxes_face_detector.py b/faceboxes_pytorch/faceboxes_face_detector.py index 835cafc6..c9c93fdb 100755 --- a/faceboxes_pytorch/faceboxes_face_detector.py +++ b/faceboxes_pytorch/faceboxes_face_detector.py @@ -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()