Skip to content

Commit

Permalink
Filter oob while computing crop size
Browse files Browse the repository at this point in the history
  • Loading branch information
gitttt-1234 committed Dec 17, 2024
1 parent f00afd6 commit ed56b36
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sleap/nn/data/instance_cropping.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ def find_instance_crop_size(

# Calculate crop size
min_crop_size_no_pad = min_crop_size - padding
height, width, _ = labels[0].image.shape
max_length = 0.0
for inst in labels.user_instances:
pts = inst.points_array

pts[pts < 0] = np.NaN
pts[:, 0][pts[:, 0] > height - 1] = np.NaN
pts[:, 1][pts[:, 1] > width - 1] = np.NaN

pts *= input_scaling
max_length = np.maximum(max_length, np.nanmax(pts[:, 0]) - np.nanmin(pts[:, 0]))
max_length = np.maximum(max_length, np.nanmax(pts[:, 1]) - np.nanmin(pts[:, 1]))
Expand Down

0 comments on commit ed56b36

Please sign in to comment.