-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Np average #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Np average #353
Conversation
@@ -63,7 +63,7 @@ def visualize(image: np.ndarray, | |||
""" | |||
for person in list_persons: | |||
if person.score < instance_threshold: | |||
continue | |||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you break instead of continue? We implemented this function with multiple pose model in mind, so we only skip instances that are below the instance threshold.
@@ -108,6 +108,7 @@ def person_from_keypoints_with_scores( | |||
# Calculate person score by averaging keypoint scores. | |||
scores_above_threshold = list( | |||
filter(lambda x: x > keypoint_score_threshold, scores)) | |||
scores_above_threshold = np.append(scores_above_threshold, 0) | |||
person_score = np.average(scores_above_threshold) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should do this instead. If you add a zero, it will change the average value.
person_score = np.average(scores_above_threshold) if scores_above_threshold else 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I have already fixed it.
In the file https://github.com/Charlie839242/examples/blob/master/lite/examples/pose_estimation/raspberry_pi/data.py, 111 line, it is possible that the score of 17 keypoints all don't reach the threshold. In this case, the np.average receives a empty list, which will cause some warnings like:
RuntimeWarning: Mean of empty slice.
RuntimeWarning: invalid value encountered in double_scalars
By adding 'scores_above_threshold = np.append(scores_above_threshold, 0)' can solve the problem.