1adrianb / face-alignment

:fire: 2D and 3D Face alignment library build using pytorch
https://www.adrianbulat.com
BSD 3-Clause "New" or "Revised" License
6.89k stars 1.33k forks source link

Error loading blazeface detector #222

Closed felmoreno1726 closed 3 years ago

felmoreno1726 commented 3 years ago

I get an error loading the blazeface model. I tried different versions of pytorch, they give different errors but both crash on the same line when trying to load the weights from the url.

Torch version: 1.7.0:

File "main.py", line 128, in fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, device=args.device, face_detector=args.face_detector) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/face_alignment/api.py", line 69, in init self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/face_alignment/detection/blazeface/blazeface_detector.py", line 33, in init model_weights = load_url(models_urls['blazeface_weights']) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/torch/hub.py", line 559, in load_state_dict_from_url return torch.load(cached_file, map_location=map_location) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/torch/serialization.py", line 595, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/torch/serialization.py", line 764, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: invalid load key, '\x0a'.

Torch version: 1.2.0 File "main.py", line 128, in fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, device=args.device, face_detector=args.face_detector) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/face_alignment/api.py", line 69, in init self.face_detector = face_detector_module.FaceDetector(device=device, verbose=verbose) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/face_alignment/detection/blazeface/blazeface_detector.py", line 33, in init model_weights = load_url(models_urls['blazeface_weights']) File "/home/pipemon/projects/Gaze/GazeController/venv/lib/python3.6/site-packages/torch/hub.py", line 461, in load_state_dict_from_url hash_prefix = HASH_REGEX.search(filename).group(1) AttributeError: 'NoneType' object has no attribute 'group'

1adrianb commented 3 years ago

I just tried to reproduce this but I was unable to so I presume it's something specific to your setup. The first error suggests that either the model was corrupted during download or the encoding used is different. You can easily narrow this down by downloading the models_urls manually and then try to load them.

felmoreno1726 commented 3 years ago

Interesting. I deleted the blazeface.pth checkpoint weights, ran again and everything worked fine. Seems like it was likely a corrupted download. Thank you @1adrianb. Closing this now.