Skip to content

Commit

Permalink
add threshold asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
cospectrum committed Jan 4, 2025
1 parent 35b97bc commit 68544a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/microwink/seg.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def apply(
assert image.width > 0
assert image.height > 0

raw = self._run(image, threshold.confidence, threshold.iou)
assert 0.0 <= threshold.iou <= 1.0
assert 0.0 <= threshold.confidence <= 1.0

raw = self._run(image, threshold.confidence, iou_threshold=threshold.iou)
if raw is None:
return []

Expand Down
3 changes: 3 additions & 0 deletions tests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def test_samples(
actual = img.copy()
for card, box in zip(cards, boxes):
assert 0.0 < card.score < 1.0
assert card.mask.min() >= 0.0
assert card.mask.max() <= 1.0
assert round_box(card.box) == box

actual = draw_box(actual, card.box)
actual = draw_mask(actual, card.mask > BIN_THRESHOLD)
assert truth == actual

0 comments on commit 68544a1

Please sign in to comment.