NoduleNet icon indicating copy to clipboard operation
NoduleNet copied to clipboard

Test trained model on single image

Open valbertoenoc opened this issue 4 years ago • 7 comments

Hello ,

Is it possible to run the trained model on a single CT scan? I've tried loading the provided checkpoint and running inference on a single CT scan, but ran into a number of problem. But the most relevant one is that the net forward method expects a number of inputs, truth_bboxes, masks, etc. I've also tried using the eval_single function, so I assumed the model was ready to receive a single ct scan input.

I appreciate the attention.

valbertoenoc avatar May 09 '20 14:05 valbertoenoc

I am sorry that we did not provide such a script. But there are ways for doing that.

One easy way is to set those arguments (truth_boxes, masks) to None. Those GT arguments are used only in training mode (https://github.com/uci-cbcl/NoduleNet/blob/master/net/nodule_net.py#L365-L374).

tanghaotommy avatar May 10 '20 04:05 tanghaotommy

Thanks for answering! I did pass the first error, but the second got me confused. What is exactly the expected input of the network. Is it a scan patch or the whole scan for inference?

I tried passing a whole scan, but got this error: RuntimeError: Expected 5-dimensional input for 5-dimensional weight 24 1 3 3 3, but got 4-dimensional input of size [1, 100, 512, 512] instead

I'm so sorry to disturb you at all on this matter.

valbertoenoc avatar May 11 '20 00:05 valbertoenoc

The input is the 3D CT scan. PyTorch expects a 5-dimensional input for volumetric data. So your input should be [batch_size, channel, depth, height, width]. You need to add one more dimension to your input, e.g. using torch.unsqueeze(tensor, 0)

tanghaotommy avatar May 13 '20 01:05 tanghaotommy

Hello Tang, that helped, thanks a lot. I have a couple of follow up questions though:

  1. I was able to run a forward pass, but got and GPU memory allocation error. I have a 1050Ti 4gb. How much memory is necessary to run a single scan?

  2. I couldn't make it run on the CPU because of DataParallel, I´m not familiar of how to use it.

  3. I was able to run only a single time, after that I got the following error without changing anything to the process, and I have no idea why. Would you happen to know something about this error? This is my input shape : [1,1,133,512,512]

Error:

comb2 = self.back2(torch.cat((rev2, out2), 1))#64+64 RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 33 and 32 in dimension 2 at C:/w/1/s/tmp_conda_3.6_171155/conda/conda-bld/pytorch_1570813991702/work/aten/src\THC/generic/THCTensorMath.cu:71

Thank you again.

valbertoenoc avatar May 23 '20 14:05 valbertoenoc

can you find the function average_precision()?

LXYTSOS avatar Jun 23 '20 02:06 LXYTSOS

@valbertoenoc

  1. We use 1080ti with 12GB as minimum requirement. The alternative is to generate input patches with fixed size (e.g. 12812812) using sliding window.
  2. You may need to modify the code in order to run on CPU. We only tested on GPU
  3. This error is because the size of each dimension of the input must be a multiply of 16, as we downsample the input volume 4 times

tanghaotommy avatar Jun 24 '20 18:06 tanghaotommy

Excuse me,sir?!may I ask you for some help? my emil is [email protected]

thank you very much!

913620614 avatar Apr 16 '22 08:04 913620614