當前位置: 首頁>>代碼示例>>Python>>正文


Python util.KNNIds方法代碼示例

本文整理匯總了Python中utils.util.KNNIds方法的典型用法代碼示例。如果您正苦於以下問題:Python util.KNNIds方法的具體用法?Python util.KNNIds怎麽用?Python util.KNNIds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils.util的用法示例。


在下文中一共展示了util.KNNIds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GenerateImitationVideo

# 需要導入模塊: from utils import util [as 別名]
# 或者: from utils.util import KNNIds [as 別名]
def GenerateImitationVideo(
    vid_name, query_ims, query_embs, target_ims, target_embs, height, width):
  """Generates a single cross-sequence imitation video.

  For each frame in some query sequence, find the nearest neighbor from
  some target sequence in embedding space.

  Args:
    vid_name: String, the name of the video.
    query_ims: Numpy array of shape [query sequence length, height, width, 3].
    query_embs: Numpy array of shape [query sequence length, embedding size].
    target_ims: Numpy array of shape [target sequence length, height, width,
      3].
    target_embs: Numpy array of shape [target sequence length, embedding
      size].
    height: Int, height of the raw image.
    width: Int, width of the raw image.
  """
  # For each query frame, find the index of the nearest neighbor in the
  # target video.
  knn_indices = [util.KNNIds(q, target_embs, k=1)[0] for q in query_embs]

  # Create and write out the video.
  assert knn_indices
  knn_ims = np.array([target_ims[k] for k in knn_indices])
  MakeImitationVideo(FLAGS.outdir, vid_name, query_ims, knn_ims, height, width) 
開發者ID:rky0930,項目名稱:yolo_v2,代碼行數:28,代碼來源:generate_videos.py


注:本文中的utils.util.KNNIds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。