Skip to content

Commit 03eacf1

Browse files
committed
Merge branch 'dev' into merging-metatensor
Signed-off-by: Wenqi Li <[email protected]>
2 parents df51ef4 + 78509ae commit 03eacf1

File tree

9 files changed

+29
-19
lines changed

9 files changed

+29
-19
lines changed

.github/workflows/weekly-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
export YEAR_WEEK=$(date +'%y%U')
3434
echo "Year week for tag is ${YEAR_WEEK}"
3535
if ! [[ $YEAR_WEEK =~ ^[0-9]{4}$ ]] ; then echo "Wrong 'year week' format. Should be 4 digits."; exit 1 ; fi
36-
git tag "0.9.dev${YEAR_WEEK}"
36+
git tag "0.10.dev${YEAR_WEEK}"
3737
git log -1
3838
git tag --list
3939
python setup.py sdist bdist_wheel

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ title: "MONAI: Medical Open Network for AI"
66
abstract: "AI Toolkit for Healthcare Imaging"
77
authors:
88
- name: "MONAI Consortium"
9-
date-released: 2022-02-16
10-
version: "0.8.1"
9+
date-released: 2022-06-13
10+
version: "0.9.0"
1111
identifiers:
1212
- description: "This DOI represents all versions of MONAI, and will always resolve to the latest one."
1313
type: doi

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ RUN BUILD_MONAI=1 FORCE_CUDA=1 python setup.py develop \
3838

3939
# NGC Client
4040
WORKDIR /opt/tools
41-
ARG NGC_CLI_URI="https://ngc.nvidia.com/downloads/ngccli_cat_linux.zip"
42-
RUN wget -q ${NGC_CLI_URI} && \
43-
unzip ngccli_cat_linux.zip && chmod u+x ngc && \
44-
md5sum -c ngc.md5 && \
45-
rm -rf ngccli_cat_linux.zip ngc.md5
41+
ARG NGC_CLI_URI="https://ngc.nvidia.com/downloads/ngccli_linux.zip"
42+
RUN wget -q ${NGC_CLI_URI} && unzip ngccli_linux.zip && chmod u+x ngc-cli/ngc && \
43+
find ngc-cli/ -type f -exec md5sum {} + | LC_ALL=C sort | md5sum -c ngc-cli.md5 && \
44+
rm -rf ngccli_linux.zip ngc-cli.md5
45+
ENV PATH=${PATH}:/opt/tools:/opt/tools/ngc-cli
4646
RUN apt-get update \
4747
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y libopenslide0 \
4848
&& rm -rf /var/lib/apt/lists/*

docs/source/mb_specification.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ metadata.json File
5757

5858
This file contains the metadata information relating to the model, including what the shape and format of inputs and outputs are, what the meaning of the outputs are, what type of model is present, and other information. The JSON structure is a dictionary containing a defined set of keys with additional user-specified keys. The mandatory keys are as follows:
5959

60-
* **version**: version of the stored model, this allows multiple versions of the same model to be differentiated.
60+
* **version**: version of the stored model, this allows multiple versions of the same model to be differentiated. Versions should follow semantic versioning and contain only characters valid in filenames as we may include the version to construct bundle file name.
6161
* **monai_version**: version of MONAI the bundle was generated on, later versions expected to work.
6262
* **pytorch_version**: version of Pytorch the bundle was generated on, later versions expected to work.
6363
* **numpy_version**: version of Numpy the bundle was generated on, later versions expected to work.

monai/metrics/generalized_dice.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,15 @@ def compute_generalized_dice(
169169
numer = 2.0 * (intersection * w).sum(dim=1)
170170
denom = (denominator * w).sum(dim=1)
171171

172-
# Compute the score. Where the denominator (and numerator) is 0, score is 1
172+
# Compute the score
173173
generalized_dice_score = numer / denom
174-
generalized_dice_score[denom == 0] = 1
175174

176-
# Compute the final score, replacing nans (where denominator is 0)
175+
# Handle zero deivision. Where denom == 0 and the prediction volume is 0, score is 1.
176+
# Where denom == 0 but the prediction volume is not 0, score is 0
177+
y_pred_o = y_pred_o.sum(dim=-1)
178+
denom_zeros = denom == 0
179+
generalized_dice_score[denom_zeros] = torch.where(
180+
(y_pred_o == 0)[denom_zeros], torch.tensor(1.0), torch.tensor(0.0)
181+
)
182+
177183
return generalized_dice_score

monai/transforms/spatial/array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,9 @@ class RandRotate(RandomizableTransform, InvertibleTransform):
13451345
range_x: Range of rotation angle in radians in the plane defined by the first and second axes.
13461346
If single number, angle is uniformly sampled from (-range_x, range_x).
13471347
range_y: Range of rotation angle in radians in the plane defined by the first and third axes.
1348-
If single number, angle is uniformly sampled from (-range_y, range_y).
1348+
If single number, angle is uniformly sampled from (-range_y, range_y). only work for 3D data.
13491349
range_z: Range of rotation angle in radians in the plane defined by the second and third axes.
1350-
If single number, angle is uniformly sampled from (-range_z, range_z).
1350+
If single number, angle is uniformly sampled from (-range_z, range_z). only work for 3D data.
13511351
prob: Probability of rotation.
13521352
keep_size: If it is False, the output shape is adapted so that the
13531353
input array is contained completely in the output.

monai/transforms/spatial/dictionary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,9 @@ class RandRotated(RandomizableTransform, MapTransform, InvertibleTransform):
13321332
range_x: Range of rotation angle in radians in the plane defined by the first and second axes.
13331333
If single number, angle is uniformly sampled from (-range_x, range_x).
13341334
range_y: Range of rotation angle in radians in the plane defined by the first and third axes.
1335-
If single number, angle is uniformly sampled from (-range_y, range_y).
1335+
If single number, angle is uniformly sampled from (-range_y, range_y). only work for 3D data.
13361336
range_z: Range of rotation angle in radians in the plane defined by the second and third axes.
1337-
If single number, angle is uniformly sampled from (-range_z, range_z).
1337+
If single number, angle is uniformly sampled from (-range_z, range_z). only work for 3D data.
13381338
prob: Probability of rotation.
13391339
keep_size: If it is False, the output shape is adapted so that the
13401340
input array is contained completely in the output.

tests/test_compute_generalized_dice.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@
107107

108108
TEST_CASE_6 = [{"y": torch.ones((2, 2, 3, 3)), "y_pred": torch.ones((2, 2, 3, 3))}, [1.0000, 1.0000]]
109109

110-
TEST_CASE_7 = [{"y": torch.zeros((2, 2, 3, 3)), "y_pred": torch.ones((2, 2, 3, 3))}, [1.0000, 1.0000]]
110+
TEST_CASE_7 = [{"y": torch.zeros((2, 2, 3, 3)), "y_pred": torch.ones((2, 2, 3, 3))}, [0.0000, 0.0000]]
111+
112+
TEST_CASE_8 = [{"y": torch.ones((2, 2, 3, 3)), "y_pred": torch.zeros((2, 2, 3, 3))}, [0.0000, 0.0000]]
113+
114+
TEST_CASE_9 = [{"y": torch.zeros((2, 2, 3, 3)), "y_pred": torch.zeros((2, 2, 3, 3))}, [1.0000, 1.0000]]
111115

112116

113117
class TestComputeMeanDice(unittest.TestCase):
114118
# Functional part tests
115-
@parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_6, TEST_CASE_7])
119+
@parameterized.expand([TEST_CASE_1, TEST_CASE_2, TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_9])
116120
def test_value(self, input_data, expected_value):
117121
result = compute_generalized_dice(**input_data)
118122
np.testing.assert_allclose(result.cpu().numpy(), expected_value, atol=1e-4)

tests/test_detection_coco_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_coco_run(self):
5959
gt_classes=[val_data_i["labels"].numpy() for val_data_i in val_targets_all],
6060
)
6161
val_epoch_metric_dict = coco_metric(results_metric)[0]
62-
np.testing.assert_array_less([-0.01], [sum(val_epoch_metric_dict.values())])
62+
np.testing.assert_array_less([-16.01], [sum(val_epoch_metric_dict.values())])
6363

6464

6565
if __name__ == "__main__":

0 commit comments

Comments
 (0)