MaskGAN icon indicating copy to clipboard operation
MaskGAN copied to clipboard

Some questions about testing~

Open zky0701 opened this issue 1 year ago • 13 comments

Hello author, I was thinking about changing the model mode to test when running the test, but an error occurred:‘ no module name models.test_model’, I also encountered the same error when replacing dataset_made unaligned to single. What is the reason for this? Looking forward to your reply very much.

zky0701 avatar Jan 03 '25 06:01 zky0701

Hi @zky0701. Are you using the test.py file?

victorcaquilpan avatar Jan 03 '25 06:01 victorcaquilpan

Hi @zky0701. Are you using the test.py file?

Thank you for your reply. Yes, I am using test. py. Strangely, when I run the test. py file, the files under the val_A and val_B files are also read and tested, not just the test_A and test_B. Is this normal? Or what part do you want to modify?

zky0701 avatar Jan 03 '25 06:01 zky0701

The dataset part is handle mostly by the script "unaligned_dataset.py". Try to keep using it. Specifically, where did you get the error "...models.test_model..."? There is not any function or package "test_model" in the repo. Could you provide a screenshot or more information?

victorcaquilpan avatar Jan 03 '25 06:01 victorcaquilpan

The dataset part is handle mostly by the script "unaligned_dataset.py". Try to keep using it. Specifically, where did you get the error "...models.test_model..."? There is not any function or package "test_model" in the repo. Could you provide a screenshot or more information?

When I change -- model to test and -- dataset_mode to single, there is an error as shown in the figure. We look forward to your reply. test single

zky0701 avatar Jan 03 '25 07:01 zky0701

Hi @zky0701. Please, use --model mask_gan and --dataset_mode unaligned. There is not a model "test". About the datataset_mode, we set everything based on the unaligned script.

victorcaquilpan avatar Jan 05 '25 01:01 victorcaquilpan

Hi @zky0701. Please, use --model mask_gan and --dataset_mode unaligned. There is not a model "test". About the datataset_mode, we set everything based on the unaligned script.

Okay,thanks a lot!

zky0701 avatar Jan 05 '25 05:01 zky0701

Hi @zky0701. Please, use --model mask_gan and --dataset_mode unaligned. There is not a model "test". About the datataset_mode, we set everything based on the unaligned script.

Sorry to bother you again, author. I have another question. Why is there data in the valA and valB folders instead of just the data in the test folder in the test_desult I obtained while running test.xpy? The arrangement of my folder directory is as follows. May I ask if there are any implicit calls to the test. py file? 微信截图_20250111195603

zky0701 avatar Jan 11 '25 11:01 zky0701

The valA and valB folders are used just for validation during the training process (to check how the model goes during the training)

victorcaquilpan avatar Jan 13 '25 03:01 victorcaquilpan

The valA and valB folders are used just for validation during the training process (to check how the model goes during the training)

Thank you for taking the time to answer, but I have one more question. When I was running test. py, I set the parameters image_2 to 256 * 256 and pre-processing to none. However, when I checked the results, I found that the size of my image had been changed to 224 * 224. May I ask what caused this problem? What hyperparameter settings are related to modifying the image size during the test phase? I am looking forward to your answer!

zky0701 avatar Jan 13 '25 06:01 zky0701

Hi @zky0701, by the way, have you checked the preprocess script? The next function is available in https://github.com/HieuPhan33/MaskGAN/blob/master/preprocess/main.pyin the line 152. Here, we are resizing images to 214, 214, 214, but adding also a padding. In that way we can get the input images with size 224, 224, 224. You can modify this as your convenience.

def save_slice(img, mask, data_dir, data_mask_dir, filename): assert img.shape == mask.shape, f"Shape not match - img {img.shape} vs mask {mask.shape}" pad_width = ((5, 5), (5, 5), (5, 5)) # Resize to 204,204,204 img = resize_volume(img, 214,214,214) img = np.pad(img, pad_width, mode='constant', constant_values=0) mask = resize_volume(mask, 214,214,214) mask = np.pad(mask, pad_width, mode='constant', constant_values=0)

victorcaquilpan avatar Jan 14 '25 06:01 victorcaquilpan

Thank you for your reply.Yes, I have reviewed all the code in the main. py file during preprocessing and obtained the desired image size. However, when I ran test. py and set the --preprocess parameter to none, the size of the test result was changed. Is this related to the code in line 152 of preprocessing that you mentioned?

zky0701 avatar Jan 14 '25 07:01 zky0701

In our repo, the preprocessing is done in two stages.

Firstly, in order to align images in a general way you need to run the script: https://github.com/HieuPhan33/MaskGAN/blob/master/preprocess/main.py. In that way, you go to create the input folders (train, val, test) and set the images in a "generic" format.

Secondly, during training a new preprocessing could be carried out. Here, you can resize, pad and crop the image to a different format if you need. This is process controlled by the argument "--preprocess" when you are training or testing. So, even if you set "--preprocess none", this doesn't affect the preprocessing in the first stage.

victorcaquilpan avatar Jan 14 '25 07:01 victorcaquilpan

In our repo, the preprocessing is done in two stages.

Firstly, in order to align images in a general way you need to run the script: https://github.com/HieuPhan33/MaskGAN/blob/master/preprocess/main.py. In that way, you go to create the input folders (train, val, test) and set the images in a "generic" format.

Secondly, during training a new preprocessing could be carried out. Here, you can resize, pad and crop the image to a different format if you need. This is process controlled by the argument "--preprocess" when you are training or testing. So, even if you set "--preprocess none", this doesn't affect the preprocessing in the first stage.

Thank you very much for your quick response, I will try it out based on your answer, thank you again!

zky0701 avatar Jan 15 '25 03:01 zky0701