0

How do I modify a single batch to multiple batches? I am currently using Yolov3 for my work. I tried to modify it according to the sample but it didn't finish my work. Could anyone please tell me how to use the multi-batch method?

Sample

std::unique_ptr<zdl::DlSystem::ITensor> loadInputTensorBatched (std::unique_ptr<zdl::SNPE::SNPE> & snpe, cv::Mat& img_raw, cv::Mat& img_raw2)
{
    std::unique_ptr<zdl::DlSystem::ITensor> input;
    const auto &strList_opt = snpe->getInputTensorNames();
    if (!strList_opt) throw std::runtime_error("Error obtaining Input tensor names");


    const auto &strList = *strList_opt;
    assert (strList.size() == 1);
    std::vector<float> inputVec;

    float* img_raw_rgb_swap1 = new float[416 * 256 * 3];
    float* img_raw_rgb_swap2 = new float[416 * 256 * 3];

    memcpy(img_raw_rgb_swap1, img_raw.data, 416 * 256 * 3 * sizeof(float));
    std::vector<float> MobileNet_yolo_image1(img_raw_rgb_swap1, img_raw_rgb_swap1 + 319488); //416*256*3

    memcpy(img_raw_rgb_swap2, img_raw2.data, 416 * 256 * 3 * sizeof(float));
    std::vector<float> MobileNet_yolo_image2(img_raw_rgb_swap2, img_raw_rgb_swap2 + 319488); //416*256*3

    inputVec.insert(inputVec.end(), MobileNet_yolo_image1.begin(), MobileNet_yolo_image1.end());
    inputVec.insert(inputVec.end(), MobileNet_yolo_image2.begin(), MobileNet_yolo_image2.end());


    const auto &inputDims_opt = snpe->getInputDimensions(strList.at(0));
    const auto &inputShape = *inputDims_opt;

    input = zdl::SNPE::SNPEFactory::getTensorFactory().createTensor(inputShape);

    std::copy(inputVec.begin(), inputVec.end(), input->begin());

    delete [] img_raw_rgb_swap1;
    delete [] img_raw_rgb_swap2;

    return input;
}
user16217248
  • 3,119
  • 19
  • 19
  • 37
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Feb 24 '23 at 14:09

0 Answers0