Skip to content
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

AddChannel, AsChannelFirst, AsChannelLast, EnsureChannelFirst, Identity, RepeatChannel #2840

Merged
merged 16 commits into from
Aug 27, 2021

Conversation

rijobro
Copy link
Contributor

@rijobro rijobro commented Aug 25, 2021

Description

Torch transforms:
AddChannel, AsChannelFirst, AsChannelLast, EnsureChannelFirst, Identity, RepeatChannel.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests.

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
…ty, RepeatChannel

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro requested review from wyli and Nic-Ma August 25, 2021 10:56
monai/transforms/utility/array.py Outdated Show resolved Hide resolved
monai/transforms/utility/array.py Outdated Show resolved Hide resolved
rijobro and others added 3 commits August 25, 2021 15:59
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@wyli
Copy link
Contributor

wyli commented Aug 25, 2021

/build

1 similar comment
@madil90
Copy link
Contributor

madil90 commented Aug 25, 2021

/build

@wyli
Copy link
Contributor

wyli commented Aug 26, 2021

/build

@rijobro
Copy link
Contributor Author

rijobro commented Aug 26, 2021

@wyli could you help me with the blossom error? I'm not sure what version of python/pytorch/OS it's running to be able to replicate the error. (It's also strange that the displayed error hasn't shown up in any of the other checks.)

@wyli
Copy link
Contributor

wyli commented Aug 26, 2021

yes, I'm also aware of the bug yesterday, still couldn't figure it out. It looks like a shared testing file cache is dirty, I'm working on it.

according to the log the test is running for this commit 9266581 but I couldn't find the corresponding branch/PR. Do you know which branch that commit is pushed to?

@rijobro
Copy link
Contributor Author

rijobro commented Aug 26, 2021

I deleted some of my branches after they were merged, so I can't find out which commit that one belonged to. Sorry!

That said, the error does look like it's related to this PR. I was just surprised that it didn't show up for the other testing environments.

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@wyli
Copy link
Contributor

wyli commented Aug 26, 2021

/build

@wyli
Copy link
Contributor

wyli commented Aug 26, 2021

the last run error was

======================================================================
FAIL: test_shape_3 (tests.test_as_channel_lastd.TestAsChannelLastd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_lastd.py", line 36, in test_shape
    self.assertTupleEqual(result["image"].shape, expected_shape)
AssertionError: Tuples differ: torch.Size([2, 3, 1, 4]) != (2, 3, 4, 1)

First differing element 2:
1
4

- torch.Size([2, 3, 1, 4])
+ (2, 3, 4, 1)

======================================================================
FAIL: test_shape_4 (tests.test_as_channel_lastd.TestAsChannelLastd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_lastd.py", line 36, in test_shape
    self.assertTupleEqual(result["image"].shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 3, 2, 4]) != (1, 3, 4, 2)

First differing element 2:
2
4

- torch.Size([1, 3, 2, 4])
+ (1, 3, 4, 2)

======================================================================
FAIL: test_shape_5 (tests.test_as_channel_lastd.TestAsChannelLastd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_lastd.py", line 36, in test_shape
    self.assertTupleEqual(result["image"].shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 2, 4, 3]) != (1, 2, 3, 4)

First differing element 2:
4
3

- torch.Size([1, 2, 4, 3])
+ (1, 2, 3, 4)

======================================================================
FAIL: test_shape_6 (tests.test_as_channel_lastd.TestAsChannelLastd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_lastd.py", line 36, in test_shape
    self.assertTupleEqual(result["image"].shape, expected_shape)
AssertionError: Tuples differ: torch.Size([2, 3, 1, 4]) != (2, 3, 4, 1)

First differing element 2:
1
4

- torch.Size([2, 3, 1, 4])
+ (2, 3, 4, 1)

======================================================================
FAIL: test_shape_7 (tests.test_as_channel_lastd.TestAsChannelLastd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_lastd.py", line 36, in test_shape
    self.assertTupleEqual(result["image"].shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 3, 2, 4]) != (1, 3, 4, 2)

First differing element 2:
2
4

- torch.Size([1, 3, 2, 4])
+ (1, 3, 4, 2)

======================================================================
FAIL: test_shape_8 (tests.test_as_channel_lastd.TestAsChannelLastd)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_lastd.py", line 36, in test_shape
    self.assertTupleEqual(result["image"].shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 2, 4, 3]) != (1, 2, 3, 4)

First differing element 2:
4
3

- torch.Size([1, 2, 4, 3])
+ (1, 2, 3, 4)

======================================================================
FAIL: test_shape_3 (tests.test_as_channel_last.TestAsChannelLast)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_last.py", line 32, in test_shape
    self.assertTupleEqual(result.shape, expected_shape)
AssertionError: Tuples differ: torch.Size([2, 3, 1, 4]) != (2, 3, 4, 1)

First differing element 2:
1
4

- torch.Size([2, 3, 1, 4])
+ (2, 3, 4, 1)

======================================================================
FAIL: test_shape_4 (tests.test_as_channel_last.TestAsChannelLast)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_last.py", line 32, in test_shape
    self.assertTupleEqual(result.shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 3, 2, 4]) != (1, 3, 4, 2)

First differing element 2:
2
4

- torch.Size([1, 3, 2, 4])
+ (1, 3, 4, 2)

======================================================================
FAIL: test_shape_5 (tests.test_as_channel_last.TestAsChannelLast)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_last.py", line 32, in test_shape
    self.assertTupleEqual(result.shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 2, 4, 3]) != (1, 2, 3, 4)

First differing element 2:
4
3

- torch.Size([1, 2, 4, 3])
+ (1, 2, 3, 4)

======================================================================
FAIL: test_shape_6 (tests.test_as_channel_last.TestAsChannelLast)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_last.py", line 32, in test_shape
    self.assertTupleEqual(result.shape, expected_shape)
AssertionError: Tuples differ: torch.Size([2, 3, 1, 4]) != (2, 3, 4, 1)

First differing element 2:
1
4

- torch.Size([2, 3, 1, 4])
+ (2, 3, 4, 1)

======================================================================
FAIL: test_shape_7 (tests.test_as_channel_last.TestAsChannelLast)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_last.py", line 32, in test_shape
    self.assertTupleEqual(result.shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 3, 2, 4]) != (1, 3, 4, 2)

First differing element 2:
2
4

- torch.Size([1, 3, 2, 4])
+ (1, 3, 4, 2)

======================================================================
FAIL: test_shape_8 (tests.test_as_channel_last.TestAsChannelLast)
----------------------------------------------------------------------

tests finished, printing completed times >10.0s in ascending order...

test_cpu_precise_backwards_7_3_dimension_1_channel_high_spatial_sigma_high_color_sigma (tests.test_bilateral_precise.BilateralFilterTestCaseCpuPrecise) (10.8s)
test_script (tests.test_highresnet.TestHighResNet) (11.4s)
test_script_0 (tests.test_senet.TestSENET) (11.5s)
test_shape_0 (tests.test_efficientnet.TestExtractFeatures) (11.7s)
test_cuda_3_1_batches_3_dimensions_1_channels_2_classes_1_mixtures (tests.test_gmm.GMMTestCase) (12.1s)
test_cuda_2_1_batches_2_dimensions_2_channels_4_classes_4_mixtures (tests.test_gmm.GMMTestCase) (12.2s)
test_cuda_1_1_batches_1_dimensions_5_channels_2_classes_1_mixtures (tests.test_gmm.GMMTestCase) (12.3s)
test_cuda_0_2_batches_1_dimensions_1_channels_2_classes_2_mixtures (tests.test_gmm.GMMTestCase) (13.0s)
test_lr_finder (tests.test_lr_finder.TestLRFinder) (28.9s)
test_senet_shape_0 (tests.test_senet.TestPretrainedSENET) (3.18e+02s)
test discovery time: 4.24s
total testing time: 4.42e+02s
Remember to check above times for any errors!

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/parameterized/parameterized.py", line 533, in standalone_func
    return func(*(a + p.args), **p.kwargs)
  File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_as_channel_last.py", line 32, in test_shape
    self.assertTupleEqual(result.shape, expected_shape)
AssertionError: Tuples differ: torch.Size([1, 2, 4, 3]) != (1, 2, 3, 4)

First differing element 2:
4
3

- torch.Size([1, 2, 4, 3])
+ (1, 2, 3, 4)

----------------------------------------------------------------------
Ran 4411 tests in 992.790s

FAILED (failures=12, skipped=408)

version:

================================
Printing MONAI config...
================================
MONAI version: 0+unknown
Numpy version: 1.19.5
Pytorch version: 1.7.1
MONAI flags: HAS_EXT = True, USE_COMPILED = True
MONAI rev id: None

Optional dependencies:
Pytorch Ignite version: 0.4.5
Nibabel version: 3.2.1
scikit-image version: 0.17.2
Pillow version: 8.3.1
Tensorboard version: 2.6.0
gdown version: 3.13.0
TorchVision version: 0.8.2
tqdm version: 4.62.2
lmdb version: 1.2.1
psutil version: 5.8.0
pandas version: 1.1.5
einops version: 0.3.0

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

rijobro and others added 2 commits August 26, 2021 15:42
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@madil90
Copy link
Contributor

madil90 commented Aug 27, 2021

/build

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro
Copy link
Contributor Author

rijobro commented Aug 27, 2021

@wyli @Nic-Ma tests are green, would you be able to review when possible? Thanks.

@rijobro rijobro enabled auto-merge (squash) August 27, 2021 13:28
Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@rijobro rijobro merged commit fe6ac0a into Project-MONAI:dev Aug 27, 2021
@rijobro rijobro deleted the utility_transforms branch August 27, 2021 15:50
wyli pushed a commit to Borda/MONAI that referenced this pull request Aug 27, 2021
wyli pushed a commit to Borda/MONAI that referenced this pull request Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants