Skip to content

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Charlie839242
Copy link

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.

@google-ml-butler google-ml-butler bot added the size:XS CL Change Size: Extra Small label Oct 19, 2021
@google-cla google-cla bot added the cla: yes CLA has been signed label Oct 19, 2021
@@ -63,7 +63,7 @@ def visualize(image: np.ndarray,
"""
for person in list_persons:
if person.score < instance_threshold:
continue
break
Copy link
Member

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)
Copy link
Member

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

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review cla: yes CLA has been signed size:XS CL Change Size: Extra Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants