The code for single image inference runs normally,but Error encountered while using code for batch inference
the error is appeared when executing the forward function " auto outputs = module.forward({ inputs });":
0x00007FFEE6F1CF19 处(位于 torchscript_mask_rcnn.exe 中)有未经处理的异常: Microsoft C++ 异常: c10::Error,位于内存位置 0x000000B8A5CFE2B0 处。
Instructions To Reproduce the 🐛 Bug:
int main() {
}
2 . one picture inference code:
c10::IValue get_scripting_inputs(cv::Mat& img, c10::Device device) { const int height = img.rows; const int width = img.cols; const int channels = 3;
auto img_tensor = torch::from_blob(img.data, {height, width, channels}, torch::kUInt8); cout << "img_tensor define" << endl; // HWC to CHW img_tensor = img_tensor.to(device, torch::kFloat).permute({2, 0, 1}).contiguous(); cout << "------------------tensor to device:" << device << endl; c10::Dict dic = c10::Dict<std::string, torch::Tensor>(); dic.insert("image", img_tensor); cout << "------------get_scripting_inputs finish------" << endl; return std::make_tuple(dic); } int main() {
torch::jit::script::Module module = load_model();
auto device = (*begin(module.buffers())).device();
string image_path = "D:/VsProjects/d2_deploy/test_pic"; vector src_name;
glob(image_path, src_name);
for (int i = 0; i <src_name.size(); i++) {
} return 0; }
Expected behavior:
The code for single image inference runs normally,but Error encountered while using code for batch inference
the error is appeared when executing the forward function " auto outputs = module.forward({ inputs });": 0x00007FFEE6F1CF19 处(位于 torchscript_mask_rcnn.exe 中)有未经处理的异常: Microsoft C++ 异常: c10::Error,位于内存位置 0x000000B8A5CFE2B0 处。
Environment:
win10+libtorch2.1.1+cuda12.1+pytorch2.1.1+opencv4.8