Skip to content

Commit

Permalink
feat(#54): add scores of each stages in log
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Sep 8, 2019
1 parent 449f250 commit cc899a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions stagesepx/classifier/svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def __init__(self,
feature_type = 'hog'
if feature_type not in self.FEATURE_DICT:
raise AttributeError(f'no feature func named {feature_type}')
self.feature_func = self.FEATURE_DICT[feature_type]
self._model = None
self.feature_func: typing.Callable = self.FEATURE_DICT[feature_type]
self._model: typing.Optional[LinearSVC] = None
logger.debug(f'feature function: {feature_type}')

def clean_model(self):
Expand Down Expand Up @@ -127,7 +127,10 @@ def predict_with_object(self, pic_object: np.ndarray) -> str:
"""
pic_object = self.feature_func(pic_object)
pic_object = pic_object.reshape(1, -1)
return self._model.predict(pic_object)[0]
# scores for each stages
scores = self._model.decision_function(pic_object)[0]
logger.debug(f'scores: {scores}')
return self._model.classes_[np.argmax(scores)]

def _classify_frame(self,
frame_id: int,
Expand Down

0 comments on commit cc899a7

Please sign in to comment.