russel0719 / UNet-3-Plus-Pytorch

Unofficial Pytorch Implementation of UNet3Plus: A Full-Scale Connected UNet for Medical Image Segmentation
MIT License
5 stars 2 forks source link

Inferencing command #1

Closed walli-like closed 3 months ago

walli-like commented 3 months ago

image is that wrong?

russel0719 commented 3 months ago

Hi, @walli-like

Thank you for your point Your idea is right. I fixed README.md file correctly. If you have some help, feel free to ask me questions.

Thank you.

walli-like commented 3 months ago

Hi, @walli-like

Thank you for your point Your idea is right. I fixed README.md file correctly. If you have some help, feel free to ask me questions.

Thank you.

@russel0719 Thank you for your reply, and your project really helps me a lot, the training result is mutch better than unet, but I still have doubts about how to use the predict.py.

  1. To predict masks from input images, where should I put the input images? According to predict.py, it seems to load images from /data/val/images ? But the folder contains validation images for training ?
  2. If I just run python predict.py MODEL.TYPE=unet3plus just as you metion above, an error has occurred image I change the INPUT.HEIGHT=240, INPUT.HEIGHT=240 when training due to my poor machine, does that have an effect?
russel0719 commented 3 months ago

Hi, I'm glad to hear that my project can help you a lot.

I apologize for using confusing filename. I used predict.py for validating valid dataset before. So I fixed code that predict.py is for inferencing image(test) and validate.py is for validating image(val).

  1. So if you want to inference images after training, you should put each images and masks(optional) in DATASET.TEST.IMAGES_PATH and DATASET.TEST.MASK_PATH.
  2. I'm not sure which image has invalid shape among image, mask, and prediction. But all images should have shape (H, W) or (H, W, C). I can figure out problems well if you check shape of images(image, mask, prediction) in front of predict.py line 87.

I hope this answers can help you. Thank you for your interest in my project.

walli-like commented 3 months ago

Hi, I'm glad to hear that my project can help you a lot.

I apologize for using confusing filename. I used predict.py for validating valid dataset before. So I fixed code that predict.py is for inferencing image(test) and validate.py is for validating image(val).

  1. So if you want to inference images after training, you should put each images and masks(optional) in DATASET.TEST.IMAGES_PATH and DATASET.TEST.MASK_PATH.
  2. I'm not sure which image has invalid shape among image, mask, and prediction. But all images should have shape (H, W) or (H, W, C). I can figure out problems well if you check shape of images(image, mask, prediction) in front of predict.py line 87.

I hope this answers can help you. Thank you for your interest in my project.

@russel0719 For question 2 finally I found the reason in prediction.py line 68
image = batch_images[index].cpu().numpy() in my case now image is [3, 240, 240] means shape(C, H, W), so I just swap the elements in image to [240, 240, 3] and then I can inference images codes is as blow: image = image.swapaxes(0, 1) image = image.swapaxes(1, 2)

I hope this can make your project better, thank you again for your patience to help me

russel0719 commented 3 months ago

@walli-like Thank you for your tests. I fixed the code. I'm sorry for late reply

Thank you!