Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/accuracy_checker/accuracy_checker/adapters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ AccuracyChecker supports following set of adapters:
* `joining_method` - method used to join embeddings (optional, supported methods are `sum` and `concatenation`, default - `sum`).
* `target_out` - target output layer name (Optional, if not provided first in the model will be used).
* `keep_shape` - allow keeping initial shape for predicted embedding (Optional, default `False`, it means that model output will be flattenized).
* `mean_pooling` - average the embeddings of all tokens from last_hidden_state (Optional, default `False`)
* `yolo_v2` - converting output of YOLO v2 family models to `DetectionPrediction` representation.
* `classes` - number of detection classes (default 20).
* `anchors` - anchor values provided as comma-separated list or one of precomputed:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2018-2024 Intel Corporation
Copyright (c) 2018-2025 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,9 @@ def parameters(cls):
choices=['sum', 'concatenation']
),
'target_out': StringField(optional=True, description='Target output layer name'),
'keep_shape': BoolField(optional=True, default=False, description='keep output embedding shape')
'keep_shape': BoolField(optional=True, default=False, description='keep output embedding shape'),
'mean_pooling': BoolField(optional=True, default=False,
description='Average the embeddings of all tokens for last_hidden_state')
})

return parameters
Expand All @@ -54,6 +56,7 @@ def configure(self):
self.joining_method = self.get_value_from_config('joining_method')
self.target_out = self.get_value_from_config('target_out')
self.keep_shape = self.get_value_from_config('keep_shape')
self.mean_pooling = self.get_value_from_config('mean_pooling')

def process(self, raw, identifiers, frame_meta):
"""
Expand All @@ -67,6 +70,10 @@ def process(self, raw, identifiers, frame_meta):
raw_prediction = self._extract_predictions(raw, frame_meta)
prediction = raw_prediction[self.output_blob]

if self.mean_pooling:
# Shape: (1, 128, 768) -> (1, 768)
prediction = np.mean(prediction, axis=1)

if self.grn_workaround:
# workaround: GRN layer
prediction = self._grn_layer(prediction)
Expand Down
Loading