models.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:crossnet 作者: viibridges 项目源码 文件源码
def compute_indexing(source_size, target_size):
  # source_size is the size of reference feature map, where (0,0) 
  # corresponds to the top-left corner and (1,1) corresponds to the 
  # bottom-right conner of the feature map.

  jj, ii = np.meshgrid(range(source_size[1]), range(source_size[0]), indexing='xy')
  xx, yy = np.meshgrid(range(target_size[1]), range(target_size[0]), indexing='xy')
  X, I = np.meshgrid(xx.flatten(), ii.flatten(), indexing='xy')
  Y, J = np.meshgrid(yy.flatten(), jj.flatten(), indexing='xy')

  # normalize to 0 and 1
  I = I.astype('float32') / (source_size[0]-1)
  J = J.astype('float32') / (source_size[1]-1)
  Y = Y.astype('float32') / (target_size[0]-1)
  X = X.astype('float32') / (target_size[1]-1)

  indexing = tf.stack([I, J, Y, X], axis=2)

  return tf.expand_dims(indexing, 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号