Skip to content

Commit

Permalink
fix polygon loader test (#385)
Browse files Browse the repository at this point in the history
* fix polygon loader test

* precommit

---------

Co-authored-by: Benjamin Morris <[email protected]>
  • Loading branch information
benjijamorris and Benjamin Morris authored Jun 25, 2024
1 parent 4e8677d commit 27f1075
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_polygon_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

def test_load_polygon(tmp_path):
# create random image and find contours
image = random_shapes((500, 500), max_shapes=1, num_channels=1)[0].squeeze()
image[image == 255] = 0
image = random_shapes((500, 500), max_shapes=1, num_channels=1, random_seed=3)[0].squeeze()
# create polygon from background
image = image == 255
contours = find_contours(label(image))

# Convert contours to polygons and save
Expand All @@ -24,8 +25,8 @@ def test_load_polygon(tmp_path):
reconstructed = transform(data)["poly"][0]

# Check that the reconstructed mask is the close to as the original
iou = np.sum(np.logical_and(reconstructed[0], image > 0)) / np.sum(
np.logical_or(reconstructed[0], image > 0)
iou = np.sum(np.logical_and(reconstructed[0] > 0, image > 0)) / np.sum(
np.logical_or(reconstructed[0] > 0, image > 0)
)

assert iou > 0.8
Expand Down

0 comments on commit 27f1075

Please sign in to comment.