Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix save masks bug #332

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions samgeo/samgeo.py
Original file line number Diff line number Diff line change
@@ -265,8 +265,8 @@ def save_masks(

# Generate a mask of objects with unique values
if unique:
# Sort the masks by area in ascending order
sorted_masks = sorted(masks, key=(lambda x: x["area"]), reverse=False)
# Sort the masks by area in descending order
sorted_masks = sorted(masks, key=(lambda x: x["area"]), reverse=True)

# Create an output image with the same size as the input image
objects = np.zeros(
@@ -276,9 +276,10 @@ def save_masks(
)
)
# Assign a unique value to each object
count = len(sorted_masks)
for index, ann in enumerate(sorted_masks):
m = ann["segmentation"]
objects[m] = index + 1
objects[m] = count - index

# Generate a binary mask
else:
7 changes: 4 additions & 3 deletions samgeo/samgeo2.py
Original file line number Diff line number Diff line change
@@ -293,8 +293,8 @@ def save_masks(

# Generate a mask of objects with unique values
if unique:
# Sort the masks by area in ascending order
sorted_masks = sorted(masks, key=(lambda x: x["area"]), reverse=False)
# Sort the masks by area in descending order
sorted_masks = sorted(masks, key=(lambda x: x["area"]), reverse=True)

# Create an output image with the same size as the input image
objects = np.zeros(
@@ -304,9 +304,10 @@ def save_masks(
)
)
# Assign a unique value to each object
count = len(sorted_masks)
for index, ann in enumerate(sorted_masks):
m = ann["segmentation"]
objects[m] = index + 1
objects[m] = count - index

# Generate a binary mask
else: