代码页面:https://github.com/syedmohsinbukhari/resnet_libtorch/blob/master/use_resnet.cpp
#include <torch/script.h> // One-stop header.
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <chrono>
#include <iostream>
#include <memory>
using namespace std::chrono;
int main(int argc, const char* argv[]) {
if (argc != 3) {
std::cerr << "usage: resnet_libtorch <path-to-resnet-script-module> <path-to-input-image>\n";
return -1;
}
// Configuration
int input_image_size = 224;
int batc