sergivalverde / nicMSlesions

Easy multiple sclerosis white matter lesion segmentation using convolutional deep neural networks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Batch Dimension squeeze

StinkyBenji opened this issue · comments

Hey Sergi, I was training some dataset using nicMSlesions, however, the following error occurred.

Screenshot from 2020-11-19 09-03-08

So I guess there is one batch shape for a subject is (1,2,11,11,11), and in base.py, test_scan, line 551: y_pred = model['net'].predict(np.squeeze(batch),options['batch_size'])
you used np.squeeze(batch), so the shape becomes (2, 11, 11, 11)?
So do you think I can simply modify the script by adding a condition after np.squeeze the batch or
sqz_batch = np.squeeze(batch)
if len(sqz_batch.shape) < 5:
sqz_batch = np.expand_dims(sqz_batch, axis = 0)
else....

Looking forward to your reply.
Thanks

Hi,

Looks like for this particular image, it exists only one lesion patch [1,2,11,11,11] so it's squeezed. What you suggest may work. Maybe you can delete the np.squeeze in line 551?

Let me know what it does.

s

Hey,
ystd I used the condition that I suggested in the base.py and ran the process for a small epoch on a small training set, there was no error occurring anymore. Bcs I wasn't sure what's ur initial intention for using np.squeeze(), thus I didn't want to simply delete it.. Anyway the modified script works just fine :)

Dear Sergi,
I am having the same problem, but it occurs when I try to infer the segmentation.
error_teste_imagem
What's the best way to solve it?

Kind regards,
Isabella

Update:
I deleted the np.squeeze, as suggested before and it's working fine.