Rewrite noise filter of visualization logic #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I thought the original code
if np.unique(predictions[-10:])[0]==np.argmax(res):
was a filter: that would allow probability evaluation if the current frame is classified as the most frequent class of the past 10 frames. However, as I read more closely, I found out that the code will check if the class index of the current frame is the smallest class index of the classifications of the past 10 frames. In the case of your video, thisif
statement will always see if current frame's class is 'hello' if any one of the past ten frames were classified as 'hello'(since your action classes are['hello', 'thanks', 'iloveyou']
).By using
np.bincount
, theif
statement now evaluates the current frame's class with the most frequent class of the past ten frames.np.bincount
has its takeaway as the total class number increases, so does the memory size.If I have misunderstood your intention in the
if
statement, please let me know.