mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
[fix] check for input number of faces
This commit is contained in:
parent
041773232f
commit
c44af00269
@ -207,12 +207,14 @@ def analyze(
|
|||||||
age_predictions = model.predict(faces_array)
|
age_predictions = model.predict(faces_array)
|
||||||
|
|
||||||
# Handle single vs multiple age predictions
|
# Handle single vs multiple age predictions
|
||||||
if len(age_predictions.shape) == 1:
|
if faces_array.shape[0] == 1:
|
||||||
# Single face case - reshape predictions to 2D array for consistent handling
|
# Single face case - reshape predictions to 2D array for consistent handling
|
||||||
age_predictions = age_predictions.reshape(1, -1)
|
resp_objects[idx]["age"] = int(np.argmax(age_predictions))
|
||||||
|
else:
|
||||||
|
# Multiple face case - iterate over each prediction
|
||||||
for idx, age in enumerate(age_predictions):
|
for idx, age in enumerate(age_predictions):
|
||||||
resp_objects[idx]["age"] = np.argmax(age)
|
resp_objects[idx]["age"] = int(age)
|
||||||
|
|
||||||
|
|
||||||
elif action == "gender":
|
elif action == "gender":
|
||||||
# Build the gender model
|
# Build the gender model
|
||||||
|
Loading…
x
Reference in New Issue
Block a user