Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test trained model on single image #20

Open
valbertoenoc opened this issue May 9, 2020 · 7 comments
Open

Test trained model on single image #20

valbertoenoc opened this issue May 9, 2020 · 7 comments

Comments

@valbertoenoc
Copy link

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.

@tanghaotommy
Copy link
Collaborator

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).

@valbertoenoc
Copy link
Author

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.

@tanghaotommy
Copy link
Collaborator

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)

@valbertoenoc
Copy link
Author

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.

@LXYTSOS
Copy link

LXYTSOS commented Jun 23, 2020

can you find the function average_precision()?

@tanghaotommy
Copy link
Collaborator

@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

@913620614
Copy link

Excuse me,sir?!may I ask you for some help? my emil is 913620614@qq.com

thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants