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

Run inference with pytorch 1.11 and numpy > 1.20 #344

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 1 addition & 9 deletions echofilter/data/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def __init__(self, output_size, order=1):
self.order = order

def __call__(self, sample):

order = self.order
if order is None:
order = np.random.randint(1)
Expand All @@ -148,7 +147,7 @@ def __call__(self, sample):
"ignore", "Bi-quadratic interpolation behavior has changed"
)
sample[key] = skimage.transform.resize(
np.asarray(sample[key]).astype(np.float),
np.asarray(sample[key]).astype(float),
self.output_size,
order=order,
clip=False,
Expand Down Expand Up @@ -224,7 +223,6 @@ def __init__(self, *args, p=0.5, **kwargs):
self.p = p

def __call__(self, sample):

if random.random() > self.p:
# Nothing to do
return sample
Expand Down Expand Up @@ -341,7 +339,6 @@ def __init__(self, output_size, p=0.5, sigma=8.0, alpha=0.05, order=1):
self.alpha = _pair(alpha)

def __call__(self, sample):

if random.random() > self.p:
# Nothing to do
return sample
Expand Down Expand Up @@ -464,7 +461,6 @@ def __init__(self, center, deviation, robust2stdev=True):
self.robust2stdev = robust2stdev

def __call__(self, sample):

if not isinstance(self.center, str):
center = self.center
elif self.center.lower() == "mean":
Expand Down Expand Up @@ -521,7 +517,6 @@ def __init__(self, nan_val=0.0):
self.nan_val = nan_val

def __call__(self, sample):

# Can't use np.nan_to_num to assign nan to a specific value if
# numpy version <= 1.17.
sample["signals"][np.isnan(sample["signals"])] = self.nan_val
Expand All @@ -546,7 +541,6 @@ def __init__(self, axis=0, p=0.5):
self.p = p

def __call__(self, sample):

if random.random() > self.p:
# Nothing to do
return sample
Expand Down Expand Up @@ -575,7 +569,6 @@ def __init__(self, max_crop_fraction):
self.max_crop_fraction = max_crop_fraction

def __call__(self, sample):

width = sample["signals"].shape[0]

crop_fraction = random.uniform(0.0, self.max_crop_fraction)
Expand Down Expand Up @@ -716,7 +709,6 @@ def __init__(
self.fraction_close = fraction_close

def __call__(self, sample):

p = random.random()

# Possibility of doing no crop at all
Expand Down
7 changes: 6 additions & 1 deletion echofilter/nn/modules/pathing.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ def forward(self, x1, x2):
if diffX != 0 or diffY != 0:
x1 = F.pad(
x1,
[diffX // 2, diffX - diffX // 2, diffY // 2, diffY - diffY // 2],
[
torch.div(diffX, 2, rounding_mode="trunc"),
diffX - torch.div(diffX, 2, rounding_mode="trunc"),
torch.div(diffY, 2, rounding_mode="trunc"),
diffY - torch.div(diffY, 2, rounding_mode="trunc"),
],
mode="replicate",
)
# if you have padding issues, see
Expand Down
2 changes: 1 addition & 1 deletion echofilter/raw/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def transect_loader(
timestamps = np.empty((n_lines - skip_lines))
timestamps[:] = np.nan

row_lengths = np.empty((n_lines - skip_lines), dtype=np.int)
row_lengths = np.empty((n_lines - skip_lines), dtype=int)
row_depth_starts = np.empty((n_lines - skip_lines))
row_depth_ends = np.empty((n_lines - skip_lines))

Expand Down