1adrianb / 1adrianb/face-alignment
At least one stride in the given numpy array is negative
- Vorherrschende Sprache
- Python
- Sterne
- 7.5k
- Forks
- 1.4k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- numpy, python, pytorch
- Bereich
- computer-vision
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 65/100