question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transforms need to handle list of channel-first data

See original GitHub issue

Is your feature request related to a problem? Please describe. Currently, if using the default collate_fn, the interted data is a list of channel-first Tensor or numpy array, if we want to apply transforms on the data, most of the MONAI transforms can’t support it. For example, users want to use CopyItemsd, AsDiscreted, KeepLargestConnectedComponentd, etc. All these transforms can only support a batch-first Tensor or a channel-first numpy array.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
Nic-Macommented, May 27, 2021

Hi @vfdev-5 ,

You are right, no need to totally change ignite metrics, but may need your help to add some wrapper layer in ignite to support a list of channel-first tensors or support 1 channel-first tensor. We usually use ignite metrics in MONAI workflows directly, like this Accuracy: https://github.com/Project-MONAI/tutorials/blob/master/modules/engines/unet_evaluation_dict.py#L111 Actually, I already added support for list of channel-first tensors in MONAI metrics: https://github.com/Project-MONAI/MONAI/blob/dev/monai/handlers/iteration_metric.py#L91

Thanks.

1reaction
vfdev-5commented, May 26, 2021

Hi @Nic-Ma ,

As I know, ignite metrics expect the data shape with batch dim, may I know some design reason for that?

In our practice it is the most common format for the models output and targets: (B, C, ...) and (B, ...). Also it helps to accelerate internal computations.

As I understand you would like to handle additionally two lists instead of tensors ?

metric.update((
    [ypred0, ypred1, ypred2, ...],
    [y0, y1, y2, ...],
))

where ypredX and yX have shapes [C, ...] and [...] or yX can be even a scalar. I thinks this could be a feature for ignite…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transforms — MONAI 1.1.0 Documentation
Return a Composition with a simple list of transforms, as opposed to any ... img ( Tensor ) – data to be transformed,...
Read more >
A Gentle Introduction to Channels-First and Channels-Last ...
Color images have height, width, and color channel dimensions. ... Deep learning neural networks require that image data be provided as ...
Read more >
Using Oracle Data Transforms
In a web browser that has network access to the Oracle Data Transforms ... These options display the list of data entities based...
Read more >
How do I display a single image in PyTorch? - Stack Overflow
Given a Tensor representing the image, use .permute() to put the channels as the last dimension: plt.imshow( tensor_image.permute(1, 2, 0) ).
Read more >
transforms.conf - Splunk Documentation
This setting specifies the format of the event, including any field names or values you want to add. * FORMAT is required for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found