Closed Yffy123456 closed 1 year ago
HI @Yffy123456, the definition of SwinUNETR can be specified with several arguments. Below is an example:
import torch
from monai.networks.nets import SwinUNETR
x = torch.rand(1, 1, 96, 96, 96)
model = SwinUNETR(
img_size=[96, 96, 96],
in_channels=1,
out_channels=3,
feature_size=48,
)
y = model(x)
print(y.shape)
The output:
torch.Size([1, 3, 96, 96, 96])
Thanks.
I'm trying to calculate pamars its calculations and I'm having some problems
if name == 'main': x = torch.rand(1, 1, 96, 96, 96) model =SwinUNETR() model.cuda() y = model(x) print(y.shape)
/home/wf/anaconda3/envs/nnFormer0/bin/python /home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py Traceback (most recent call last): File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 990, in
model =SwinUNETR()
File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 113, in init
self.swinViT = SwinTransformer(
File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 934, in init
layer = BasicLayer(
File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 815, in init
[
File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 816, in
SwinTransformerBlock(
File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 549, in init
self.attn = WindowAttention(
File "/home/wf/anaconda3/envs/nnFormer0/lib/python3.8/site-packages/monai/networks/nets/swin_unetr.py", line 437, in init
coords = torch.stack(torch.meshgrid(coords_d, coords_h, coords_w, indexing="ij"))
TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not NoneType
Looking forward to getting your recovery