You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行deepmac_colab.ipynb遇TypeError:意外关键字参数'box_ind'求助

解决reframe_box_masks_to_image_masks的box_ind参数错误

这个错误是因为TensorFlow Object Detection API中reframe_box_masks_to_image_masks函数的参数定义在不同版本中发生了变化,导致prediction_function的调用不兼容当前API版本。以下是两种可行的解决方法:

方法一:修改参数调用适配当前API版本

  1. 在笔记本中找到定义prediction_function的代码块(通常是加载模型后构建预测逻辑的部分),定位到内部调用reframe_box_masks_to_image_masks的位置。
  2. 根据当前使用的Object Detection API版本调整参数:
    • 如果API版本没有box_ind参数(较新版本常见),删除调用中的box_ind参数。例如,将:
      reframe_box_masks_to_image_masks(box_masks, box_ind, boxes, image_height, image_width)
      
      修改为:
      reframe_box_masks_to_image_masks(box_masks, boxes, image_height, image_width)
      
    • 如果API版本需要box_ind参数(旧版本),补充该参数。例如,添加与box数量匹配的索引数组:
      box_ind = tf.range(tf.shape(boxes)[0])
      reframe_box_masks_to_image_masks(box_masks, box_ind, boxes, image_height, image_width)
      

方法二:锁定兼容的版本组合

确保TensorFlow与Object Detection API版本严格匹配:

  • 若使用TensorFlow 2.8.0,安装对应版本的Object Detection API:
    pip install tensorflow-object-detection-api==2.8.0
    
  • 若使用TensorFlow 2.14.0,安装最新兼容版本的API:
    pip install tensorflow-object-detection-api==2.14.0
    

额外验证

确认你的预标注框格式正确:

  • 框坐标需为**归一化的[y_min, x_min, y_max, x_max]**格式
  • 确保boxes变量是二维numpy数组或TensorFlow张量,维度为(N, 4),N是框的数量

内容的提问来源于stack exchange,提问作者AnonX

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 12:25:10