ChannelViT icon indicating copy to clipboard operation
ChannelViT copied to clipboard

KeyError: 'channels'

Open Boom5426 opened this issue 1 year ago • 2 comments

If I just want to use it in other field, what should I do?

import torch model = torch.hub.load('insitro/ChannelViT', 'cpjump_cellpaint_channelvit_small_p8_with_hcs_supervised', pretrained=True) model.eval() images = torch.randn(5, 3, 224, 224) out = model(images)

KeyError: 'channels'

Boom5426 avatar Sep 17 '24 07:09 Boom5426

What param shoud I input the extra_tokens?

Boom5426 avatar Sep 17 '24 07:09 Boom5426

extra_tokens["channels"] should contain channel indices per batch and should be of shape batch_size x n_channels.

For example, in the ImageNet dataset, we return a dictionary containing channels per sample which is collated using pytorch default_collate function. default_collate collates Mapping[K, V_i] -> Mapping[K, default_collate([V_1, V_2, …])] resulting in extra_tokens['channels'] of shape batch_size x n_channels.

also discussed in https://github.com/insitro/ChannelViT/issues/3#issuecomment-2027716674

srinivasans-insitro avatar Oct 24 '24 00:10 srinivasans-insitro