hukkelas / DSFD-Pytorch-Inference

A High-Performance Pytorch Implementation of face detection models, including RetinaFace and DSFD
Apache License 2.0
218 stars 58 forks source link

DSFDDetector creation problem #7

Closed rkinas closed 4 years ago

rkinas commented 4 years ago

I encountered probem with DSFDDetector creation (rest of detectors work without any problem) .. Any idea for fixing problem?

detector = face_detection.build_detector("DSFDDetector",confidence_threshold=.5, nms_iou_threshold=.3)

raises error


FileNotFoundError Traceback (most recent call last)

in ----> 1 detector = face_detection.build_detector("DSFDDetector",confidence_threshold=.5, nms_iou_threshold=.3) ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\face_detection\build.py in build_detector(name, confidence_threshold, nms_iou_threshold, device, max_resolution) 28 max_resolution=max_resolution 29 ) ---> 30 detector = build_from_cfg(args, DETECTOR_REGISTRY) 31 return detector ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\face_detection\registry.py in build_from_cfg(cfg, registry, **kwargs) 70 else: 71 raise TypeError('type must be a str or valid type, but got {}'.format(type(obj_type))) ---> 72 return obj_cls(**args, **kwargs) ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\face_detection\dsfd\detect.py in __init__(self, *args, **kwargs) 21 model_url, 22 map_location=torch_utils.get_device(), ---> 23 progress=True) 24 self.net = SSD(resnet152_model_config) 25 self.net.load_state_dict(state_dict) ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\torch\hub.py in load_state_dict_from_url(url, model_dir, map_location, progress, check_hash) 507 cached_file = os.path.join(model_dir, extraced_name) 508 --> 509 return torch.load(cached_file, map_location=map_location) ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module, **pickle_load_args) 582 pickle_load_args['encoding'] = 'utf-8' 583 --> 584 with _open_file_like(f, 'rb') as opened_file: 585 if _is_zipfile(opened_file): 586 with _open_zipfile_reader(f) as opened_zipfile: ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\torch\serialization.py in _open_file_like(name_or_buffer, mode) 232 def _open_file_like(name_or_buffer, mode): 233 if _is_path(name_or_buffer): --> 234 return _open_file(name_or_buffer, mode) 235 else: 236 if 'w' in mode: ~\AppData\Local\r-miniconda\envs\aivision\lib\site-packages\torch\serialization.py in __init__(self, name, mode) 213 class _open_file(_opener): 214 def __init__(self, name, mode): --> 215 super(_open_file, self).__init__(open(name, mode)) 216 217 def __exit__(self, *args): FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\remek/.cache\\torch\\checkpoints\\'
rkinas commented 4 years ago

I found a solution and probably bug in code ...

file: detect.py

model_url = "http://folk.ntnu.no//haakohu/WIDERFace_DSFD_RES152.pth"

should be

model_url = "http://folk.ntnu.no/haakohu/WIDERFace_DSFD_RES152.pth"

works fine for me

hukkelas commented 4 years ago

Thanks for pointing out the error! Please notify me with any others you encounter, as I've only tested my code on macOS and ubuntu 16.04/18.04.

Error fixed with: https://github.com/hukkelas/DSFD-Pytorch-Inference/commit/36fda4eaf2e07d507c6ab4827edffdcf5d8dd1e7