PaddlePaddle / FastDeploy

⚡️An Easy-to-use and Fast Deep Learning Model Deployment Toolkit for ☁️Cloud 📱Mobile and 📹Edge. Including Image, Video, Text and Audio 20+ main stream scenarios and 150+ SOTA models with end-to-end optimization, multi-platform and multi-framework support.
https://www.paddlepaddle.org.cn/fastdeploy
Apache License 2.0
2.81k stars 441 forks source link

yolo系列多batch推理有误 #2446

Open LorenzoSun-V opened 2 months ago

LorenzoSun-V commented 2 months ago

温馨提示:根据社区不完全统计,按照模板提问,可以加快回复和解决问题的速度


环境

问题日志及出现问题的操作流程

void Model::InferImagesBatch(const std::vector& batch_files){ std::vector batch_images; std::vector batch_names; std::vector batch_results; batch_images.reserve(cfg.bs);

for (const auto& file_path : batch_files) {
    auto image = cv::imread(file_path);
    if (image.empty()) {
        std::cerr << "Failed to load image: " << file_path << std::endl;
        continue; // Skip this image and continue with the next
    }
    batch_images.push_back(image);
    if (batch_images.size() == cfg.bs)
        ProcessBatchImage(batch_images, &batch_results);
}

// 处理剩余的图片(如果有)
if (!batch_images.empty())
    ProcessBatchImage(batch_images, &batch_results);

}


更多代码可以参考:[https://github.com/LorenzoSun-V/LorenzoDeploy/tree/main/fd/src](https://github.com/LorenzoSun-V/LorenzoDeploy/tree/main/fd/src)中的model.cc,核心的就是`model->BatchPredict`这个代码。
jia0511 commented 2 months ago

+1

hhx518 commented 1 month ago

+1,尤其是第一张没有结果,其他的就没有结果了