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

Filter OOB points while training #2061

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def linkcode_resolve(domain, info):
# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
'css/tabs.css',
"css/tabs.css",
]

# Custom sidebar templates, must be a dictionary that maps document names
Expand Down
20 changes: 20 additions & 0 deletions sleap/nn/data/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import attr
from typing import Text, Optional, List, Sequence, Union, Tuple
import sleap
from sleap.instance import Instance


@attr.s(auto_attribs=True)
Expand Down Expand Up @@ -198,6 +199,25 @@ def py_fetch_lf(ind):
raw_image = lf.image
raw_image_size = np.array(raw_image.shape).astype("int32")

height, width, _ = raw_image_size

# Filter OOB points
instances = []
for instance in lf.instances:
pts = instance.numpy()
# negative coords
pts[pts < 0] = np.NaN

# coordinates outside img frame
pts[:, 0][pts[:, 0] > height - 1] = np.NaN
pts[:, 1][pts[:, 1] > width - 1] = np.NaN
gitttt-1234 marked this conversation as resolved.
Show resolved Hide resolved

# remove all nans
pts = pts[~np.isnan(pts).any(axis=1), :]
gitttt-1234 marked this conversation as resolved.
Show resolved Hide resolved

instances.append(Instance.from_numpy(pts, lf.skeleton, lf.track))
lf.instances = instances
gitttt-1234 marked this conversation as resolved.
Show resolved Hide resolved

if self.user_instances_only:
insts = lf.user_instances
else:
Expand Down
Loading