Skip to content

Commit 0fa3ae5

Browse files
Fix issue in object prediction
1 parent badf7b4 commit 0fa3ae5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

micro_sam/object_classification.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ def project_prediction_to_segmentation(
210210
"""
211211
assert len(object_prediction) == len(seg_ids)
212212
prediction = {seg_id: class_pred for seg_id, class_pred in zip(seg_ids, object_prediction)}
213-
prediction[0] = 0
213+
# Find missing segmentation ids. This will include the background id, but may include other ids of small objects.
214+
# Such objects may get removed in the resizing operations.
215+
missing_ids = np.setdiff1d(np.unique(segmentation), seg_ids)
216+
prediction.update({missing_id: 0 for missing_id in missing_ids})
214217
return takeDict(prediction, segmentation)
215218

216219

0 commit comments

Comments
 (0)