Skip to content

adds a dev mode collate for diagnostic info#3684

Merged
wyli merged 3 commits intoProject-MONAI:devfrom
wyli:collate-dev
Jan 21, 2022
Merged

adds a dev mode collate for diagnostic info#3684
wyli merged 3 commits intoProject-MONAI:devfrom
wyli:collate-dev

Conversation

@wyli
Copy link
Copy Markdown
Contributor

@wyli wyli commented Jan 20, 2022

Signed-off-by: Wenqi Li [email protected]

Description

follow-up of #1833

this is a quick implementation to provide more info when collating fails.
if it's useful I can finish this PR with more tests and options

import numpy as np
import torch
from monai.data.utils import dev_collate

dev_collate(
    [
        {"img": 2, "meta": {"shape": [torch.tensor(1.0)]}},
        {"img": 3, "meta": {"shape": [np.asarray(1.0)]}},
        {"img": 4, "meta": {"shape": [torch.tensor(1.0)]}},
    ]
)

logging diagnostic info:

> collate dict key "img" out of 2 keys
> collate dict key "meta" out of 2 keys
>> collate dict key "shape" out of 1 keys
>>> collate list of sizes: [1, 1, 1].
>>>> collate/stack a list of tensors
>>>> E: expected Tensor as element 1 in argument 0, but got numpy.ndarray, while stacking ['Tensor', 'ndarray', 'Tensor'] in collate((tensor(1.), array(1.), tensor(1.)))

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • 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 --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Wenqi Li <[email protected]>
@wyli wyli requested review from Nic-Ma, ericspod and rijobro January 20, 2022 00:02
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jan 20, 2022

@wyli wyli marked this pull request as ready for review January 20, 2022 11:17
@ericspod
Copy link
Copy Markdown
Member

I think this would be useful for sure.

Copy link
Copy Markdown
Contributor

@Nic-Ma Nic-Ma 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 except for a minor comment inline.

Thanks.

@wyli wyli enabled auto-merge (squash) January 21, 2022 17:35
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jan 21, 2022

/build

1 similar comment
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jan 21, 2022

/build

@wyli wyli merged commit 32a045d into Project-MONAI:dev Jan 21, 2022
@wyli wyli deleted the collate-dev branch April 27, 2022 22:35
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.

3 participants