Closed wadesunyang closed 3 years ago
If you do not know the root cause of the problem, please post according to this template:
https://github.com/facebookresearch/detectron2/blob/master/tools/deploy/export_model.py since i use torch 1.7.1, i modify the function export_tracing(torch_model, inputs) :
assert TORCH_VERSION >= (1, 8) to assert TORCH_VERSION >= (1, 7)
./export_model.py --config-file ../../projects/PointRend/configs/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco.yaml --output ./output --export-method tracing --format torchscript MODEL.WEIGHTS detectron2://PointRend/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_coco/164254221/model_final_736f5a.pkl MODEL.DEVICE cpu
convertion is success(with some warnings). But when I run the following commad.
./build/torchscript_traced_mask_rcnn output/model.ts 1.png tracing
I get the following runtime error.
terminate called after throwing an instance of 'std::runtime_error' what(): The following operation failed in the TorchScript interpreter. Traceback of TorchScript, serialized code (most recent call last): File "code/__torch__/detectron2/export/flatten.py", line 30, in forward _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, = (_2).forward(x0, ) _24 = (_1).forward(_14, _15, _16, _17, _18, _19, _20, _21, _22, image_size, ) _25 = (_0).forward(_14, _24, _15, _16, _23, image_size, ) ~~~~~~~~~~~ <--- HERE _26, _27, _28, _29, = _25 return (_26, _27, _28, _29, image_size) File "code/__torch__/detectron2/modeling/roi_heads/roi_heads.py", line 128, in forward _63 = torch.slice(filter_inds0, 0, 0, 9223372036854775807, 1) classes = torch.select(_63, 1, 1) _64 = (_1).forward(tensor2, argument_1, classes, ) ~~~~~~~~~~~ <--- HERE _65, _66, = _64 return (tensor2, _65, _66, _61) File "code/__torch__/detectron2/projects/point_rend/mask_head.py", line 38, in forward _18 = torch.slice(point_coords_wrt_image, 0, 0, 9223372036854775807, 1) _19 = torch.slice(_18, 1, 0, 9223372036854775807, 1) _20 = torch.copy_(torch.select(_19, 2, 0), torch.view(_17, [100, 196]), False) ~~~~~~~~~~ <--- HERE _21 = torch.slice(point_coords_wrt_image, 0, 0, 9223372036854775807, 1) _22 = torch.slice(_21, 1, 0, 9223372036854775807, 1)
Traceback of TorchScript, original code (most recent call last): /home/project/detectron2/projects/PointRend/point_rend/point_features.py(218): get_point_coords_wrt_image /home/project/detectron2/projects/PointRend/point_rend/point_features.py(177): point_sample_fine_grained_features /home/project/detectron2/projects/PointRend/point_rend/mask_head.py(202): _forward_mask_coarse /home/project/detectron2/projects/PointRend/point_rend/mask_head.py(187): forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(709): _slow_forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(725): _call_impl /home/project/detectron2/detectron2/modeling/roi_heads/roi_heads.py(839): _forward_mask /home/project/detectron2/detectron2/modeling/roi_heads/roi_heads.py(769): forward_with_given_boxes /home/project/detectron2/detectron2/modeling/roi_heads/roi_heads.py(743): forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(709): _slow_forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(725): _call_impl /home/project/detectron2/detectron2/modeling/meta_arch/rcnn.py(212): inference ./export_model.py(91): inference /home/project/detectron2/detectron2/export/flatten.py(257): forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(709): _slow_forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(725): _call_impl /opt/conda/lib/python3.6/site-packages/torch/jit/_trace.py(940): trace_module /opt/conda/lib/python3.6/site-packages/torch/jit/_trace.py(742): trace ./export_model.py(100): export_tracing ./export_model.py(176): RuntimeError: shape '[100, 196]' is invalid for input of size 1176
已放弃 (核心已转储)
## Expected behavior: I was expecting to run torchscript_traced_mask_rcnn successfully. ## Environment: Paste the output of the following command:
PyTorch built with:
Can you please help to fix the issue? (By the way, mask_rcnn example can deploy success, but the PointRend is not ok .) Thank in Advance.
As the script says it does not support pytorch 1.7...
If you do not know the root cause of the problem, please post according to this template:
Instructions To Reproduce the Issue:
https://github.com/facebookresearch/detectron2/blob/master/tools/deploy/export_model.py since i use torch 1.7.1, i modify the function export_tracing(torch_model, inputs) :
convertion is success(with some warnings). But when I run the following commad.
I get the following runtime error.
Traceback of TorchScript, original code (most recent call last): /home/project/detectron2/projects/PointRend/point_rend/point_features.py(218): get_point_coords_wrt_image /home/project/detectron2/projects/PointRend/point_rend/point_features.py(177): point_sample_fine_grained_features /home/project/detectron2/projects/PointRend/point_rend/mask_head.py(202): _forward_mask_coarse /home/project/detectron2/projects/PointRend/point_rend/mask_head.py(187): forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(709): _slow_forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(725): _call_impl /home/project/detectron2/detectron2/modeling/roi_heads/roi_heads.py(839): _forward_mask /home/project/detectron2/detectron2/modeling/roi_heads/roi_heads.py(769): forward_with_given_boxes /home/project/detectron2/detectron2/modeling/roi_heads/roi_heads.py(743): forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(709): _slow_forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(725): _call_impl /home/project/detectron2/detectron2/modeling/meta_arch/rcnn.py(212): inference ./export_model.py(91): inference /home/project/detectron2/detectron2/export/flatten.py(257): forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(709): _slow_forward /opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py(725): _call_impl /opt/conda/lib/python3.6/site-packages/torch/jit/_trace.py(940): trace_module /opt/conda/lib/python3.6/site-packages/torch/jit/_trace.py(742): trace ./export_model.py(100): export_tracing ./export_model.py(176):
RuntimeError: shape '[100, 196]' is invalid for input of size 1176
已放弃 (核心已转储)
PyTorch built with:
Can you please help to fix the issue? (By the way, mask_rcnn example can deploy success, but the PointRend is not ok .) Thank in Advance.