jcwang123 / FedLC

[ECCV 2022] Personalizing Federated Medical Image Segmentation
42 stars 5 forks source link

a bug in code when using HC module #4

Open f414158949 opened 1 year ago

f414158949 commented 1 year ago

Sincere thanks for sharing the training codes!

when I set args.hc = 1, there is an error:

Traceback (most recent call last): File "scripts/train_lcfed.py", line 223, in pred, x5, hmap = net_current(volume_batch, client_idx, 1, seg_heads) File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, kwargs) File "/home/FedLC-main/scripts/../networks/lcrepnet.py", line 243, in forward o = self.forward_for_train(x, site_index, stage, seg_heads)
File "/home/FedLC-main/scripts/../networks/lcrepnet.py", line 236, in forward_for_train o = self.hc(uncertainty.detach(), preds.detach(), fea.detach()) File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, *kwargs)
File "/home/FedLC-main/scripts/../networks/lcrepnet.py", line 30, in forward fea2 = self.soft(uncertainty[:, c].unsqueeze(1), fea) + fea File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(
input,
kwargs) TypeError: forward() takes 2 positional arguments but 3 were given

jcwang123 commented 1 year ago

Please try to run the new script, "train_multi_lcfed.py"

f414158949 commented 1 year ago

thanks for fixing the code. I run the new script "train_multi_lcfed.py" and set args.hc = 1. There is also a bug during evaluation

[Test] epoch 0 testing Site 1 [2022-11-21 14:52:53,718] Traceback (most recent call last): File "scripts/train_multi_lcfed.py", line 271, in score_values = test_lc_unet(site_index, this_net, None, args) File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, kwargs) File "/home/FedLC-main/scripts/../networks/../scripts/tester_utils.py", line 159, in test_lc_unet pred = test_net(image, site_index, -1, File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, *kwargs) File "/home/FedLC-main/scripts/../networks/multi_lcnet.py", line 346, in forward o = self.forward_for_eval(x, File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, kwargs) File "/home/FedLC-main/scripts/../networks/multi_lcnet.py", line 270, in forward_for_eval uncertainty = self.get_un_map_by_head(site_index, fea, seg_heads) File "/home/anaconda3/envs/torch11/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "/home/FedLC-main/scripts/../networks/multi_lcnet.py", line 205, in get_un_map_by_head _pred = seg_headsi TypeError: 'NoneType' object is not subscriptable

And could you kindly please share the log.txt or args for training? I think it will be helpful for us to obtain reproducing results for 3 datasets in paper

jcwang123 commented 1 year ago

sorry for the bugs. I was trying to make the resources clearer after the eccv submission and modified many functions. But I'm so busy these days and thus, this repo seems confusing and some bugs occurred. I will fix the bugs and update the repo as soon as possible.

f414158949 commented 1 year ago

ok, I will be waiting for the update😊

jcwang123 commented 1 year ago

sorry for so long time delay. please see train_hc.py.