xingyizhou / CenterNet2

Two-stage CenterNet
Apache License 2.0
1.2k stars 188 forks source link

TypeError: 'NoneType' object is not iterable #81

Open GeneralJing opened 2 years ago

GeneralJing commented 2 years ago

/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2228.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Traceback (most recent call last): File "projects/CenterNet2/demo.py", line 100, in predictions, visualized_output = demo.run_on_image( File "/home/idriver/projects/CenterNet2/projects/CenterNet2/predictor.py", line 83, in run_on_image vis_output = visualizer.draw_instance_predictions( File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/detectron2-0.6-py3.8-linux-x86_64.egg/detectron2/utils/video_visualizer.py", line 111, in draw_instance_predictions else [y[0] for y in filter(lambda x: x[1], zip(labels, visibilities))] TypeError: 'NoneType' object is not iterable 本地使用的环境是在docker hub中找的一个docker环境,docker环境内部安装了detectron2,执行如下命令是可以正常显示检测结果的: python projects/CenterNet2/demo.py --config-file projects/CenterNet2/configs/CenterNet2_R50_1x.yaml --input ./images/ --opts MODEL.WEIGHTS models/CenterNet2_R50_1x.pth。 我想导出onnx model,所以使用tools/deploy/export_model.py文件,但是docker环境中的detectron2没有这个文件需要的依赖文件,所以我在docker内新建了一个虚拟环境,然后使用python setup.py build & install对本项目进行编译安装,再执行前面那个demo.py的命令的时候就报错了,对比detectron2 中的video_visualizer.py可以看出detectron2的内容是不一样的,想问下为什么会报错? 这个是detectron2的bug吗?

GeneralJing commented 2 years ago

执行export_model.py的时候,报错: ModuleNotFoundError: No module named 'detectron2.projects.point_rend'

GeneralJing commented 2 years ago

执行export_model.py的时候,报错: ModuleNotFoundError: No module named 'detectron2.projects.point_rend'

这个问题解决了,但是在导出onnx模型的时候遇到了其他问题: Traceback (most recent call last): File "tools/deploy/export_model.py", line 237, in exported_model = export_tracing(torch_model, sample_inputs) File "tools/deploy/export_model.py", line 142, in export_tracing torch.onnx.export(traceable_model, (image,), f, opset_version=11) File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/init.py", line 305, in export return utils.export(model, args, f, export_params, verbose, training, File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/utils.py", line 118, in export _export(model, args, f, export_params, verbose, training, input_names, output_names, File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/utils.py", line 719, in _export _model_to_graph(model, args, verbose, input_names, File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/utils.py", line 503, in _model_to_graph graph = _optimize_graph(graph, operator_export_type, File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/utils.py", line 232, in _optimize_graph graph = torch._C._jit_pass_onnx(graph, operator_export_type) File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/init.py", line 354, in _run_symbolic_function return utils._run_symbolic_function(*args, *kwargs) File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/utils.py", line 1061, in _run_symbolic_function return symbolic_fn(g, inputs, **attrs) File "/home/appuser/anaconda3/envs/centernet2/lib/python3.8/site-packages/torch/onnx/symbolic_opset9.py", line 2152, in repeat_interleave for idx, r_split in enumerate(r_splits): TypeError: 'torch._C.Value' object is not iterable (Occurred when translating repeat_interleave). 怎么才能正确导出onnx模型呢?