Closed serengil closed 9 months ago
this repo publishes that weight file in the url: https://github.com/akanametov/yolov8-face/releases/download/v0.0.0/yolov8n-face.pt
@serengil I check your given weights and they doesn't contain keypoints
for face-alignment like the gdrive weights.
I added this code to test in YoloWrapper.py
print(f"{WEIGHT_URL=}")
if result.keypoints:
print(f"{len(result.keypoints)=}")
else:
print("No keypoints")
Here are the results:
GDrive Weights:
WEIGHT_URL='https://drive.google.com/uc?id=1qcr9DbgsX3ryrz2uU8w4Xm3cOrRywXqb'
len(result.keypoints)=1
Repo Weights:
WEIGHT_URL='https://github.com/akanametov/yolov8-face/releases/download/v0.0.0/yolov8n-face.pt'
No keypoints
I ran the tests/test_extract_faces.py
for testing
So, we should find another source
@serengil okay ✅ , Now I will train a model and will let you know when its ready.
@serengil I trained a model on widerface-keypoints dataset. Here's the relevant files (training logs, validation predictions sample and trained-model). Can you please add the model to the deepface_models?
Unfortunately, this is not equivalent to the existing google drive model. It is coming with confidence score for landmarks and this is being actively used in yolo wrapper.
https://github.com/serengil/deepface/blob/master/deepface/detectors/Yolo.py#L94
I decided to use existing weights on google drive because this detector is not being used widely.
@serengil Hello sir i wish u can help me, when i excute this code : df = DeepFace.find(img_path='C:/Users/power/Desktop/deepface-master_2/deepface-master/img34.jpg', db_path='C:/Users/power/Desktop/deepface-master_2/deepface-master/tests/dataset/', model_name="Facenet", detector_backend="yolov8")
it shows me this error :
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_15724\1355481802.py in
D:\anaconda3\lib\site-packages\deepface\DeepFace.py in find(img_path, db_path, model_name, distance_metric, enforce_detection, detector_backend, align, expand_percentage, threshold, normalization, silent) 292 specified model and distance metric 293 """ --> 294 return recognition.find( 295 img_path=img_path, 296 db_path=db_path,
D:\anaconda3\lib\site-packages\deepface\modules\recognition.py in find(img_path, db_path, model_name, distance_metric, enforce_detection, detector_backend, align, expand_percentage, threshold, normalization, silent) 183 184 # img path might have more than once face --> 185 source_objs = detection.extract_faces( 186 img_path=img_path, 187 target_size=target_size,
D:\anaconda3\lib\site-packages\deepface\modules\detection.py in extract_faces(img_path, target_size, detector_backend, enforce_detection, align, expand_percentage, grayscale, human_readable) 87 face_objs = [DetectedFace(img=img, facial_area=base_region, confidence=0)] 88 else: ---> 89 face_objs = DetectorWrapper.detect_faces( 90 detector_backend=detector_backend, 91 img=img,
D:\anaconda3\lib\site-packages\deepface\detectors\DetectorWrapper.py in detect_faces(detector_backend, img, align, expand_percentage) 81 - confidence (float): The confidence score associated with the detected face. 82 """ ---> 83 face_detector: Detector = build_model(detector_backend) 84 85 # validate expand percentage score
D:\anaconda3\lib\site-packages\deepface\detectors\DetectorWrapper.py in build_model(detector_backend) 49 50 if face_detector: ---> 51 face_detector = face_detector() 52 face_detector_obj[detector_backend] = face_detector 53 else:
D:\anaconda3\lib\site-packages\deepface\detectors\Yolo.py in init(self) 22 class YoloClient(Detector): 23 def init(self): ---> 24 self.model = self.build_model() 25 26 def build_model(self) -> Any:
D:\anaconda3\lib\site-packages\deepface\detectors\Yolo.py in build_model(self) 55 56 # Return face_detector ---> 57 return YOLO(weight_path) 58 59 def detect_faces(self, img: np.ndarray) -> List[FacialAreaRegion]:
D:\anaconda3\lib\site-packages\ultralytics\yolo\engine\model.py in init(self, model, type) 53 54 # Load or create new YOLO model ---> 55 {'.pt': self._load, '.yaml': self._new}Path(model).suffix 56 57 def call(self, source, **kwargs):
D:\anaconda3\lib\site-packages\ultralytics\yolo\engine\model.py in _load(self, weights) 81 weights (str): model checkpoint to be loaded 82 """ ---> 83 self.model, self.ckpt = attempt_load_one_weight(weights) 84 self.ckpt_path = weights 85 self.task = self.model.args["task"]
D:\anaconda3\lib\site-packages\ultralytics\nn\tasks.py in attempt_load_one_weight(weight, device, inplace, fuse) 339 from ultralytics.yolo.utils.downloads import attempt_download 340 --> 341 ckpt = torch.load(attempt_download(weight), map_location='cpu') # load 342 args = {DEFAULT_CONFIG_DICT, ckpt['train_args']} # combine model and default args, preferring model args 343 model = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
D:\anaconda3\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module, weights_only, pickle_load_args) 807 except RuntimeError as e: 808 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None --> 809 return _load(opened_zipfile, map_location, pickle_module, pickle_load_args) 810 if weights_only: 811 try:
D:\anaconda3\lib\site-packages\torch\serialization.py in _load(zip_file, map_location, pickle_module, pickle_file, pickle_load_args) 1170 unpickler = UnpicklerWrapper(data_file, pickle_load_args) 1171 unpickler.persistent_load = persistent_load -> 1172 result = unpickler.load() 1173 1174 torch._utils._validate_loaded_sparse_tensors()
D:\anaconda3\lib\site-packages\torch\serialization.py in find_class(self, mod_name, name)
1163 pass
1164 mod_name = load_module_mapping.get(mod_name, mod_name)
-> 1165 return super().find_class(mod_name, name)
1166
1167 # Load the data (which may in turn use persistent_load
to load tensors)
AttributeError: Can't get attribute 'PoseModel' on <module 'ultralytics.nn.tasks' from 'D:\anaconda3\lib\site-packages\ultralytics\nn\tasks.py'>
Yolo wrapper is downloading weights from google drive source here. But it has daily limit, and if too many people are trying to download it in a day, gdown is failing.
This should be moved to github source similar to other weights