jcreinhold / synthtorch

deep neural network-based image translation/synthesis
Other
27 stars 7 forks source link

Error on running the example "nn-train" script #19

Closed joyschen closed 3 years ago

joyschen commented 3 years ago

Thanks for creating the tool. I tried to run the example "nn-train" script with my data "nn-train -s /data/skull/flair/ \ -t /data/skull/t2/ \ -o model_dir/unet.pth \ --nn-arch unet \ --n-layers 3 \ --n-epochs 100 \ --patch-size 64 64 64 \ --dim 3 \ --batch-size 1 \ --n-jobs 0 \ --plot-loss loss_test.png \ -vv \ --out-config-file config.json "

but I end up with the error "ERROR - Number of source and target images must be equal and non-zero" I traced the code back to line 81 in dataset.py inside the "niftidataset" package. "len(self.source_fns[0]) != len(self.target_fns[0])"

It looks like the code checks if the number of images in the source folder matches it in the target folder. However in my case, self.source_fns[0] is the path of the "source" folder, not the list of paths to images inside the folder.

Not sure if I did something wrong.

Here's the console output. "2021-03-29 16:41:21,728 - synthtorch.exec.nn_train - ERROR - Number of source and target images must be equal and non-zero Traceback (most recent call last): File "/home/jzhuo/.conda/envs/synthtorch/lib/python3.7/site-packages/synthtorch/exec/nn_train.py", line 237, in main learner = Learner.train_setup(args) File "/home/jzhuo/.conda/envs/synthtorch/lib/python3.7/site-packages/synthtorch/learn/learner.py", line 95, in train_setup train_loader, valid_loader = get_dataloader(config) File "/home/jzhuo/.conda/envs/synthtorch/lib/python3.7/site-packages/synthtorch/learn/learner.py", line 437, in get_dataloader preload=config.preload) if use_nii_ds else \ File "/home/jzhuo/.conda/envs/synthtorch/lib/python3.7/site-packages/niftidataset/dataset.py", line 83, in init raise ValueError(f'Number of source and target images must be equal and non-zero') ValueError: Number of source and target images must be equal and non-zero "

jcreinhold commented 3 years ago

Hi @joyschen. I believe I fixed the error with my latest commit 10340bf6aecbfec8e9bab24d9e98a1e3fe7c8610. Please try re-installing the package and let me know if encounter the same problem.

joyschen commented 3 years ago

Hi @jcreinhold Thanks for the quick fix. After re-installing the entire conda package, it works fine. Thank you!

jcreinhold commented 3 years ago

Thanks for the bug report and the feedback!