小编Mis*_*kyy的帖子

在 TensorFlow API 中使用批处理时,“参数无效:输出维度必须为正”

对于视频中的对象检测,我们使用大小大于 1 的批次。但是在视频结束时,当剩余帧数少于批次大小时,我们会收到以下错误:

2018-06-07 15:31:26.456907: W tensorflow/core/framework/op_kernel.cc:1290] CtxFailure at image_resizer_state.h:84: Invalid argument: output dimensions must be positive
Run Code Online (Sandbox Code Playgroud)

为了读取视频,我们使用 Opencv 3.3.0,帧存储在向量中batch

for (size_t i = 0; i < batch_size; i++) {
  ret = cap.read(readImage);
  if (!ret) {
    break;
  }
  batch.push_back(readImage.clone());
}
Run Code Online (Sandbox Code Playgroud)

该向量被转换为 tf 张量为

tensorflow::Tensor inputImg(
    tensorflow::DT_UINT8,
    tensorflow::TensorShape(
        {static_cast<long long int>(batch.size()), height, width, depth}));
for (size_t i = 0; i < batch.size(); i++) {
  auto tmp = inputImg.Slice(i, i + 1);
  uint8_t *p = tmp.flat<uint8_t>().data();
  cv::Mat cameraImg(height, width, CV_8UC3, p); …
Run Code Online (Sandbox Code Playgroud)

c++ tensorflow

5
推荐指数
0
解决办法
1897
查看次数

标签 统计

c++ ×1

tensorflow ×1