-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow numpy array passed into autothresholding function #454
base: main
Are you sure you want to change the base?
Conversation
image = image.detach().cpu().float().numpy() | ||
# Only get numpy array from torch tensor if tensor is passed in | ||
# Allows np.ndarray to be passed in directly | ||
if not isinstance(image, np.ndarray): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not a fan of reassigning an arg (I know this was already happening before the change). Could you use a new local var?
# Only get numpy array from torch tensor if tensor is passed in | ||
# Allows np.ndarray to be passed in directly | ||
if not isinstance(image, np.ndarray): | ||
image = image.detach().cpu().float().numpy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(feel free to ignore since this is out of the scope of the pr)
there's also a detach function that does the detach->cpu->numpy conversion, so this could be replaced with
img = detach(img).astype(float)
image = image.detach().cpu().float().numpy() | ||
# Only get numpy array from torch tensor if tensor is passed in | ||
# Allows np.ndarray to be passed in directly | ||
if not isinstance(image, np.ndarray): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same as below) this might be better as if isinstance(image, torch.Tensor)
What does this PR do?
Allows numpy arrays to be passed into the auththresholding function in
AutoThresh.py
while still allowing torch tensors as before.Allows thresholding to work properly