我测试的速度没有提升
int main(int argc, const char* argv[])
{
//size_t len = url.length();//获取字符串长度
char sBuf[1024];
char *ptr;
if (GetModuleFileNameA(NULL, sBuf, sizeof(sBuf)))
{
ptr = strrchr(sBuf, '\\');
if (ptr)
*ptr = '\0';
SetCurrentDirectoryA(sBuf);
}
torch::DeviceType device_type;
if (torch::cuda::is_available()) {
device_type = torch::kCUDA;
}
else {
device_type = torch::kCPU;
}
torch::Device device(device_type);
try
{
std::shared_ptr<torch::jit::script::Module> module = torch::jit::load("../models/yolo_model.pt");
assert(module != nullptr);
//module->to(at::kCUDA);
module->to(device);
torch::Tensor img_tensor = torch::rand({ 1