1adrianb / 1adrianb/face-alignment

At least one stride in the given numpy array is negative

Abierto Apto para principiantes
#259 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
7.5k
Forks
1.4k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I'm trying to use the `first-order-model`'s `crop-video.py` which calls `face-alignment` and I'm getting the following error:

```
(venv) mtg@mtg-ThinkPad-P53:~/r-projects/first-order-model$ python crop-video.py --inp drivers/laugh1.mp4
Downloading: "https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth" to /home/mtg/.cache/torch/hub/checkpoints/s3fd-619a316812.pth
100%|██████████████████████████████| 85.7M/85.7M [00:18<00:00, 4.77MB/s]
Downloading: "https://www.adrianbulat.com/downloads/python-fan/2DFAN4-cd938726ad.zip" to /home/mtg/.cache/torch/hub/checkpoints/2DFAN4-cd938726ad.zip
100%|██████████████████████████████████████████████████████████████████| 91.9M/91.9M [00:14<00:00, 6.42MB/s]
WARNING:root:Warning: the frame size for reading (1080, 1920) is different from the source frame size (1920, 1080).
0it [00:00, ?it/s]
Traceback (most recent call last):
File "crop-video.py", line 154, in
commands = process_video(args)
File "crop-video.py", line 96, in process_video
bboxes = extract_bbox(frame, fa)
File "crop-video.py", line 22, in extract_bbox
bboxes = fa.face_detector.detect_from_image(frame[..., ::-1])
File "/home/mtg/r-projects/first-order-model/venv/lib/python3.6/site-packages/face_alignment/detection/sfd/sfd_detector.py", line 44, in detect_from_image
bboxlist = detect(self.face_detector, image, device=self.device)[0]
File "/home/mtg/r-projects/first-order-model/venv/lib/python3.6/site-packages/face_alignment/detection/sfd/detect.py", line 15, in detect
img = torch.from_numpy(img).to(device, dtype=torch.float32)
ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy().) (venv) mtg@mtg-ThinkPad-P53:~/r-projects/first-order-model$ python crop-video.py --inp drivers/laugh1.mp4
Downloading: "https://www.adrianbulat.com/downloads/python-fan/s3fd-619a316812.pth" to /home/mtg/.cache/torch/hub/checkpoints/s3fd-619a316812.pth
100%|██████████████████████████████| 85.7M/85.7M [00:18<00:00, 4.77MB/s]
Downloading: "https://www.adrianbulat.com/downloads/python-fan/2DFAN4-cd938726ad.zip" to /home/mtg/.cache/torch/hub/checkpoints/2DFAN4-cd938726ad.zip
100%|██████████████████████████████████████████████████████████████████| 91.9M/91.9M [00:14<00:00, 6.42MB/s]
WARNING:root:Warning: the frame size for reading (1080, 1920) is different from the source frame size (1920, 1080).
0it [00:00, ?it/s]
Traceback (most recent call last):
File "crop-video.py", line 154, in
commands = process_video(args)
File "crop-video.py", line 96, in process_video
bboxes = extract_bbox(frame, fa)
File "crop-video.py", line 22, in extract_bbox
bboxes = fa.face_detector.detect_from_image(frame[..., ::-1])
File "/home/mtg/r-projects/first-order-model/venv/lib/python3.6/site-packages/face_alignment/detection/sfd/sfd_detector.py", line 44, in detect_from_image
bboxlist = detect(self.face_detector, image, device=self.device)[0]
File "/home/mtg/r-projects/first-order-model/venv/lib/python3.6/site-packages/face_alignment/detection/sfd/detect.py", line 15, in detect
img = torch.from_numpy(img).to(device, dtype=torch.float32)
ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy().)
```

Any idea what's going wrong here?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

The error occurs in face_alignment/detection/sfd/detect.py line 15 when converting a numpy array to a torch tensor. The array has negative strides likely from the frame[..., ::-1] slice in crop-video.py line 22. Check the frame array's memory layout and apply .copy() as suggested. Start by reproducing the issue with a test video, then modify the extract_bbox function to ensure a contiguous array is passed to detect_from_image.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
numpy, python, pytorch
Área
computer-vision
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
65/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.