Closed guanyuwang0001 closed 3 years ago
@guanyuwang0001, you interference is slow may due to you try to load weights every time you iterating.
You can move the lines below out of your for loop:
// load network
std::string weights = opt["weights"].asstd::string();
auto detector = Detector(weights, device_type);
// set up threshold
float conf_thres = opt["conf-thres"].as
@yasenh ,thank you very much.
在对您的代码进行简单修改后,使用循环读取本地文件的方式,用yolov5s模型,进行效果测试,发现推理速度只有两三帧,且查看GPU,发现GPU的占用率很小,所以想问下,该工程是不是不支持模型加载一次,而进行预测。修改代码部分如图。期待您的答复,谢谢!
`// load input image std::vector filenames;
cv::String folder = "/home/xavier/dataset/DF";
cv::glob(folder, filenames);
for(size_t i = 0; i < filenames.size(); ++i)
{
cv::Mat img = cv::imread(filenames[i]);
//std::cout<<"**"<<filenames[i]<<std::endl;
if (img.empty())
{
std::cerr << "Error loading the image!\n";
return -1;
}
// load network
std::string weights = opt["weights"].as();
auto detector = Detector(weights, device_type);
}`