Closed esterivera closed 3 years ago
Same here. Would love an update @1adrianb
edit: or let's say this is a similar error with the following message:
landmarks = align.get_landmarks_from_image(m[:, :, :3])
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\torch\autograd\grad_mode.py", line 15, in decorate_context
return func(*args, **kwargs)
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\api.py", line 140, in get_landmarks_from_image
detected_faces = self.face_detector.detect_from_image(image[..., ::-1].copy())
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\detection\blazeface\blazeface_detector.py", line 52, in detect_from_image
bboxlist = detect(self.face_detector, image, device=self.device)[0]
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\detection\blazeface\detect.py", line 24, in detect
preds = net.predict_on_image(img)
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\detection\blazeface\net_blazeface.py", line 191, in predict_on_image
return self.predict_on_batch(img.unsqueeze(0))[0]
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\detection\blazeface\net_blazeface.py", line 226, in predict_on_batch
detections = self._tensors_to_detections(out[0], out[1], self.anchors)
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\detection\blazeface\net_blazeface.py", line 261, in _tensors_to_detections
detection_boxes = self._decode_boxes(raw_box_tensor, anchors)
File "C:\Users\hendr\.conda\envs\py38\lib\site-packages\face_alignment\detection\blazeface\net_blazeface.py", line 288, in _decode_boxes
x_center = raw_boxes[..., 0] / self.x_scale * \
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Could you please try installing from source and see if it works for you? I will push a new version on pip over the weekend.
Seems to be working from source, thank you.
@ElIngeniero289 Thanks for confirming. The package was updated over the weekend so it should also be fine from pip/conda.
Confirmed from pip. Thank you!
Hello! I updated to the last version of the code, which already has support for batch 3D-landmark processing (Thank you again). However, when I tried to execute the examples with a GPU and BlazeFace,Ii get an error. These are the lines which I execute (Exactly like the example)
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, device='cuda', face_detector='blazeface')
t_start = time.time() preds = fa.get_landmarks_from_image(frames[0]) t_stop = time.time()
or for batch processing:
batch = np.stack(frames) batch = batch.transpose(0, 3, 1, 2) batch = torch.Tensor(batch[:5]).cuda() t_start = time.time() preds = fa.get_landmarks_from_batch(batch)
I get the following error:
File "/home/ubuntu/rotation/notebook.py", line 22, in <module> preds = fa.get_landmarks_from_image(frames[0]) File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context return func(*args, **kwargs) File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/api.py", line 140, in get_landmarks_from_image File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/detection/blazeface/blazeface_detector.py", line 52, in detect_from_image File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/detection/blazeface/detect.py", line 24, in detect File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/detection/blazeface/net_blazeface.py", line 191, in predict_on_image File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/detection/blazeface/net_blazeface.py", line 226, in predict_on_batch File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/detection/blazeface/net_blazeface.py", line 261, in _tensors_to_detections File "/home/ubuntu/anaconda3/envs/pytorch_latest_p36/lib/python3.6/site-packages/face_alignment-1.1.0-py3.6.egg/face_alignment/detection/blazeface/net_blazeface.py", line 289, in _decode_boxes RuntimeError: expected device cuda:0 but got device cpu
When I run the exact same code, but with face_detector='sfd', both batch and online inference work smoothly.
Any idea what is going on?