Skip to content

Commit

Permalink
[python] Fix classification usage via OVMS (#198)
Browse files Browse the repository at this point in the history
* Fix classification usage via OVMS

* Tighten the condition to filter possible non-ov adapters usage

* Add one more comment on classificaiton postprocessing
  • Loading branch information
sovrasov authored Sep 20, 2024
1 parent 0a108d7 commit 32740e5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions model_api/python/model_api/models/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@ def __init__(self, inference_adapter, configuration=dict(), preload=False):
if self.output_raw_scores:
self.out_layer_names.append(self.raw_scores_name)
except (RuntimeError, AttributeError):
self.embedded_topk = False
self.out_layer_names = _get_non_xai_names(self.outputs.keys())
self.raw_scores_name = self.out_layer_names[0]
# exception means we have a non-ov model, or a model behind OVMS
# with already inserted softmax and topk
if self.embedded_processing and len(self.outputs) >= 2:
self.embedded_topk = True
self.out_layer_names = ["indices", "scores"]
self.raw_scores_name = _raw_scores_name
else: # likely a non-ov model
self.embedded_topk = False
self.out_layer_names = _get_non_xai_names(self.outputs.keys())
self.raw_scores_name = self.out_layer_names[0]

self.embedded_processing = True

Expand Down

0 comments on commit 32740e5

Please sign in to comment.