Toybrick

rknn-toolkit\example\mobilenet-ssd中的box_priors.txt文件是如何得到的

ldol31627

中级会员

积分
310
楼主
发表于 2019-4-9 14:28:01    查看: 21967|回复: 11 | [复制链接]    打印 | 显示全部楼层
本帖最后由 ldol31627 于 2019-4-9 14:30 编辑

请问rknn-toolkit\example\mobilenet-ssd中的box_priors.txt文件是如何得到的?
我的mobilenet-ssd 输入是 640x360, 需要重新定义box_priors.txt文件。
我是用tensorflow训练的模型
回复

使用道具 举报

ldol31627

中级会员

积分
310
沙发
 楼主| 发表于 2019-4-11 13:32:55 | 显示全部楼层
解决方法:
在 tensorflow\models\research\object_detection\meta_architectures\ssd_meta_arch.py
    predictions_dict = {
        'preprocessed_inputs': preprocessed_inputs,
        'feature_maps': feature_maps,
        'anchors': self._anchors.get()
    } 代码后添加以下代码:
sess = tf.Session()
    with sess.as_default():
      anchors_np = self._anchors.get().eval()
      anchors_np = anchors_np.transpose()
      minx = anchors_np[0]
      miny = anchors_np[1]
      maxx = anchors_np[2]
      maxy = anchors_np[3]
      cx = (minx + maxx) / 2.
      cy = (miny + maxy) / 2.
      w  = maxx - minx
      h  = maxy - miny
      np.savetxt('box_priors.txt', (cx, cy, w, h), fmt='%0.8f')
即可保存 box_priors.txt 文件
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表