Skip to content

Commit

Permalink
fix(labels): correct a bug with labels passed
Browse files Browse the repository at this point in the history
  • Loading branch information
adutchak committed Jun 20, 2024
1 parent 6203cc2 commit 11b08a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,15 @@ func (r *recognizer) processImage(ctx context.Context, sourceBytes []byte) error
labelsPassed := 0
labelsTotal := len(r.configuration.ConfidencesNotLessThanNormalized) + len(r.configuration.ConfidencesNotMoreThanNormalized)
for _, label := range labelsOutput.Labels {
passed := false

for labelName, threshold := range r.configuration.ConfidencesNotLessThanNormalized {
err = verifyLabelConfidenceNotLessThan(label, labelName, threshold)
if err != nil {
// No return here, because we want to check all the labels
log.Error(err)
} else {
labelsPassed++
passed = true
}
}

Expand All @@ -269,9 +271,13 @@ func (r *recognizer) processImage(ctx context.Context, sourceBytes []byte) error
// No return here, because we want to check all the labels
log.Error(err)
} else {
labelsPassed++
passed = true
}
}

if passed {
labelsPassed++
}
}

if labelsPassed != labelsTotal {
Expand Down

0 comments on commit 11b08a0

Please sign in to comment.