Res2Net / Res2Net-maskrcnn

Res2Net for Instance segmentation and Object detection using MaskRCNN
https://mmcheng.net/res2net/
MIT License
55 stars 18 forks source link

TypeError: train() takes 2 positional arguments but 3 were given #3

Open aswa123 opened 3 years ago

aswa123 commented 3 years ago

Hello Sir, Can you please help me with this problem. I tried many ways but I cannot success in that. Error shows in line 160. Thank you.

gasvn commented 3 years ago

Please show me your error message so I can help you.

aswa123 commented 3 years ago

Traceback (most recent call last): File "/home/swap/miniconda3/envs/Res2Net-maskrcnn-master/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3427, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in runfile('/home/swap/Downloads/Res2Net-maskrcnn-master/tools/train_net.py', args=['--config-file', 'configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml', 'SOLVER.IMS_PER_BATCH', '2', 'SOLVER.BASE_LR', '0.0025', 'SOLVER.MAX_ITER', '7200', 'SOLVER.STEPS', '(480000, 640000)', 'TEST.IMS_PER_BATCH', '1'], wdir='/home/swap/Downloads/Res2Net-maskrcnn-master') File "/home/swap/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.7660.27/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "/home/swap/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.7660.27/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/swap/Downloads/Res2Net-maskrcnn-master/tools/train_net.py", line 167, in main() File "/home/swap/Downloads/Res2Net-maskrcnn-master/tools/train_net.py", line 160, in main model = train(cfg, args.local_rank, args.distributed) TypeError: train() takes 2 positional arguments but 3 were given

gasvn commented 3 years ago

Do you use the following command to train the model? export NGPUS=8 python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml"

gasvn commented 3 years ago

The train function is def train(cfg, local_rank, distributed): And it should receive 3 arguments instead of 2. I didn't find this bug when running this repo.

gasvn commented 3 years ago

How you install this repo first following https://github.com/Res2Net/Res2Net-maskrcnn/blob/master/INSTALL.md ?

gasvn commented 3 years ago

image

aswa123 commented 3 years ago

python tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1

Do you use the following command to train the model? export NGPUS=8 python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml"

aswa123 commented 3 years ago

How you install this repo first following https://github.com/Res2Net/Res2Net-maskrcnn/blob/master/INSTALL.md ?

yes.

gasvn commented 3 years ago

You can try the distributed training mode. I didn't use the python tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1 to train the model as it cannot reproduce the performance of the model zoo in maskrcnn-benchmark.

gasvn commented 3 years ago

Actually the maskrcnn-benchmark is deprecated now. We also have the res2net+mmdetection and res2net+detectron2. You can use this two repos to achieve much better performance.

aswa123 commented 3 years ago

So, now I cannot use single GPU?

gasvn commented 3 years ago

So, now I cannot use single GPU?

You cannot reproduce the result with one GPU.

aswa123 commented 3 years ago

So we cannot train with one GPU you mean?

gasvn commented 3 years ago

So we cannot train with one GPU you mean? yes

aswa123 commented 3 years ago

What should I change if I want to use single GPU? thank you.