From 5854f49908bbf457894e4368c58fe052a3d05ada Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Mon, 5 Aug 2024 13:30:44 +0100 Subject: [PATCH] feat: add _drop_lowest() to VAFE Drops lowest n% (default:33%) of scdet scores, since it scores every frame Python being what it is, this could be a single line in another method but pulling it out into another function: - makes explicit what we are doing and lets us document why - makes for easier testing --- pipeline/feature_extractors.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipeline/feature_extractors.py b/pipeline/feature_extractors.py index 05c1f7d..4fff274 100644 --- a/pipeline/feature_extractors.py +++ b/pipeline/feature_extractors.py @@ -282,6 +282,11 @@ class VideoActivityFeatureExtractor(FeatureExtractor): ) return scores + def _drop_lowest(self, scores, percent=33): + """Drop the lowest n% scores from the list""" + scores = sorted(scores, key=lambda x: x[1], reverse=True) + return scores[:int(len(scores) * (percent / 100))] + def setup(self): pass