Skip to content

Commit

Permalink
Fix test failure due to change in torchvision (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
constantinpape committed Jan 31, 2024
1 parent 8151561 commit 95216eb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions micro_sam/prompt_based_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Optional, Tuple

import numpy as np
import torch
from nifty.tools import blocking
from skimage.feature import peak_local_max
from skimage.filters import gaussian
Expand Down Expand Up @@ -87,12 +88,14 @@ def inv_sigmoid(x):

elif logits.shape[0] == logits.shape[1]: # shape is square
trafo = ResizeLongestSide(expected_shape[0])
logits = trafo.apply_image(logits[..., None])
logits = trafo.apply_image_torch(torch.from_numpy(logits[None, None]))
logits = logits.numpy().squeeze()

else: # shape is not square
# resize the longest side to expected shape
trafo = ResizeLongestSide(expected_shape[0])
logits = trafo.apply_image(logits[..., None])
logits = trafo.apply_image_torch(torch.from_numpy(logits[None, None]))
logits = logits.numpy().squeeze()

# pad the other side
h, w = logits.shape
Expand Down

0 comments on commit 95216eb

Please sign in to comment.