StefanDenn3r / Spatio-temporal-MS-Lesion-Segmentation

Code for the paper 'Spatio-temporal Learning from Longitudinal Data for Multiple Sclerosis Lesion Segmentation'
MIT License
16 stars 3 forks source link

Custom test size? #2

Open arthursw opened 3 years ago

arthursw commented 3 years ago

I try to test a model trained with 368 x 368 x 140 images, but I get the following error:

Trainable parameters: 2048500
INFO:test:Loading checkpoint: /gpfswork/rech/awn/me/ms_study/methods/spatio_temporal/data/output/saved/models/Multitask_Longitudinal_Network_EMISEP/1110_120310/checkpoint-epoch16.pth ...
  0%|                                                                                                                                                                                                                                               | 0/18768 [00:01<?, ?it/s]
Traceback (most recent call last):
  File "/gpfswork/rech/awn/me/ms_study/methods/spatio_temporal/Spatio-temporal-MS-Lesion-Segmentation/test.py", line 225, in <module>
    main(config)
  File "/gpfswork/rech/awn/me/ms_study/methods/spatio_temporal/Spatio-temporal-MS-Lesion-Segmentation/test.py", line 95, in main
    output_agg[axis][c % res] = torch.unsqueeze(slice_output.float()[1], dim=0)
RuntimeError: The expanded size of the tensor (217) must match the existing size (368) at non-singleton dimension 1.  Target sizes: [217, 217].  Tensor sizes: [368, 368]

I see in test.py that res = 217 if config['dataset_type'] == Dataset.ISBI else 229, does this mean that the test size is always fixed and must be 217 with ISBI data?

arthursw commented 3 years ago

I added the following lines in test.py after lin 59:

if config['arch']['args']['resolution'][0] > res:
        res = config['arch']['args']['resolution'][0]

but I then had troubles since my 17 test patients have only two time points ; and the script output only 2 patients, one with 4 time points and the second with 5 time points.

I guess I would have to change timestep_limit too, and I would need a model taking cubic images (res x res x res) as input.