Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

您好,我在sh run.sh之后,代码报了错TypeError: __init__() takes 1 positional argument but 4 were given,请问这个问题是什么原因呀,感谢! #17

Closed
A465539338 opened this issue Dec 22, 2020 · 4 comments

Comments

@A465539338
Copy link

[12/22 10:43:48 d2.data.common]: Serializing 117266 elements to byte tensors and concatenating them all ...
[12/22 10:43:52 d2.data.common]: Serialized dataset takes 451.21 MiB
[12/22 10:43:52 detectron2]: Using training sampler TrainingSampler
[12/22 10:43:57 detectron2]: initial from https://download.pytorch.org/models/resnet18-5c106cde.pth
[12/22 10:43:57 detectron2]: The checkpoint state_dict contains keys that are not used by the model:
fc.{weight, bias}
Traceback (most recent call last):
File "/home/yb/centerX/train_net.py", line 66, in
args=(args,),
File "/home/yb/anaconda3/envs/centernetx/lib/python3.7/site-packages/detectron2/engine/launch.py", line 59, in launch
daemon=False,
File "/home/yb/anaconda3/envs/centernetx/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 200, in spawn
return start_processes(fn, args, nprocs, join, daemon, start_method='spawn')
File "/home/yb/anaconda3/envs/centernetx/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 158, in start_processes
while not context.join():
File "/home/yb/anaconda3/envs/centernetx/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 119, in join
raise Exception(msg)
Exception:

-- Process 2 terminated with the following error:
Traceback (most recent call last):
File "/home/yb/anaconda3/envs/centernetx/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap
fn(i, *args)
File "/home/yb/anaconda3/envs/centernetx/lib/python3.7/site-packages/detectron2/engine/launch.py", line 94, in _distributed_worker
main_func(*args)
File "/home/yb/centerX/train_net.py", line 52, in main
trainer = Trainer(cfg)
File "/home/yb/centerX/engine/defaults.py", line 71, in init
super(DefaultTrainer, self).init(model, data_loader, optimizer)
TypeError: init() takes 1 positional argument but 4 were given

@CPFLAME
Copy link
Collaborator

CPFLAME commented Dec 22, 2020

可能是你的detectron2版本问题。建议按照readme中的指令安装detectron2
pip install -U 'git+https://github.com/CPFLAME/detectron2.git'

@yyticadd
Copy link

I met the same problem. I installed the latest detectron2 (python -m pip install detectron2 -f
https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html).

How can I modify your code to use the official detectron2 instead of your version? Thanks.

@A465539338
Copy link
Author

感谢作者给出的建议,我重新配置了环境并成功运行了。环境如下:

python 3.7
pytorch 1.5
cuda 10.1
detectron2 用这个来安装pip install -U 'git+https://github.com/CPFLAME/detectron2.git', 不能按照官方的命令来安装

@lixiangMindSpore
Copy link

pip install -U 'git+https://github.com/CPFLAME/detectron2.git'

image
按照指导安装不成功,请教一下,如何解决?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants