Fixed unknown face causing error
This commit is contained in:
parent
1cf74e13ed
commit
b5d95ed963
|
@ -4,9 +4,19 @@
|
|||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Quick Debug",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "wyzely_detect",
|
||||
"args": [
|
||||
"--run-scale", "0.25", "--view-scale", "0.5", "--no-remove-representations"
|
||||
],
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
// "name": "Python: Module",
|
||||
"name": "Debug Wyzely Detect",
|
||||
"name": "Full Debug",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "wyzely_detect",
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"# cv2.imwrite(str(uuid_path), frame)\n",
|
||||
"# dfs = DeepFace.find(img_path=str(uuid_path), db_path = \"faces\")\n",
|
||||
"# Don't throw an error if no face is detected (enforce_detection=False)\n",
|
||||
"dfs = DeepFace.find(frame, db_path = \"faces\", enforce_detection=False, silent=False, model_name=\"ArcFace\", detector_backend=\"opencv\")\n",
|
||||
"dfs = DeepFace.find(frame, db_path = \"faces\", enforce_detection=True, silent=False, model_name=\"ArcFace\", detector_backend=\"opencv\")\n",
|
||||
"# Get the identity of the person\n",
|
||||
"for i, pd_dataframe in enumerate(dfs):\n",
|
||||
" # Sort the dataframe by confidence\n",
|
||||
|
|
|
@ -138,7 +138,12 @@ def recognize_face(
|
|||
# The last row is the highest confidence
|
||||
# So we can just grab the path from there
|
||||
# iloc = Integer LOCation
|
||||
try:
|
||||
path_to_image = Path(df.iloc[-1]["identity"])
|
||||
# Seems this is caused when someone steps into frame and their face is detected but not recognized
|
||||
except IndexError:
|
||||
print("Face present but not recognized")
|
||||
return None
|
||||
# If the parent name is the same as the path to the database, then set label to the image name instead of the parent name
|
||||
if path_to_image.parent == Path(path_to_directory):
|
||||
label = path_to_image.name
|
||||
|
|
Loading…
Reference in New Issue