-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,10 @@ def thresh_func(image): | |
self.thresh_func = thresh_func | ||
|
||
def __call__(self, image): | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. (same as below) this might be better as |
||
image = image.detach().cpu().float().numpy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
if self.thresh_func is None: | ||
return image | ||
return (image > self.thresh_func(image)).astype(np.uint8) |
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?