-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix: make y optional in ignore_background #8647
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
74ce60d
9360ec1
5c3f448
e674ec1
47c4666
e959caf
7149489
b03357e
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 |
|---|---|---|
|
|
@@ -129,9 +129,7 @@ def compute_variance( | |
| y_pred = y_pred.float() | ||
|
|
||
| if not include_background: | ||
| y = y_pred | ||
| # TODO If this utils is made to be optional for 'y' it would be nice | ||
| y_pred, y = ignore_background(y_pred=y_pred, y=y) | ||
| y_pred, _ = ignore_background(y_pred=y_pred, y=None) | ||
|
||
|
|
||
| # Set any values below 0 to threshold | ||
| y_pred[y_pred <= 0] = threshold | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,9 @@ | |
| ] | ||
|
|
||
|
|
||
| def ignore_background(y_pred: NdarrayTensor, y: NdarrayTensor) -> tuple[NdarrayTensor, NdarrayTensor]: | ||
| def ignore_background( | ||
| y_pred: NdarrayTensor, y: NdarrayTensor | None = None | ||
| ) -> tuple[NdarrayTensor, NdarrayTensor | None]: | ||
|
Comment on lines
+58
to
+60
|
||
| """ | ||
| This function is used to remove background (the first channel) for `y_pred` and `y`. | ||
|
|
||
|
|
@@ -63,7 +65,8 @@ def ignore_background(y_pred: NdarrayTensor, y: NdarrayTensor) -> tuple[NdarrayT | |
|
|
||
|
Comment on lines
62
to
69
|
||
| """ | ||
|
|
||
| y = y[:, 1:] if y.shape[1] > 1 else y # type: ignore[assignment] | ||
| if y is not None: | ||
| y = y[:, 1:] if y.shape[1] > 1 else y # type: ignore[assignment] | ||
| y_pred = y_pred[:, 1:] if y_pred.shape[1] > 1 else y_pred # type: ignore[assignment] | ||
| return y_pred, y | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.