本文整理汇总了Python中joblib.Parallel.reverse方法的典型用法代码示例。如果您正苦于以下问题:Python Parallel.reverse方法的具体用法?Python Parallel.reverse怎么用?Python Parallel.reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类joblib.Parallel
的用法示例。
在下文中一共展示了Parallel.reverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_best_matches
# 需要导入模块: from joblib import Parallel [as 别名]
# 或者: from joblib.Parallel import reverse [as 别名]
def get_best_matches(img, ids, kps, des):
number_of_results = 3
src_kp, src_des = get_kp_desc(img)
os.remove(img)
matches = []
matches = Parallel(n_jobs=-1)(delayed(match_gen)([kp_to_list(src_kp), src_des, kp_to_list(kps[i]), des[i], ids[i]]) for i in range(len(ids)))
# remove product ids that have 0 matches
for elem in matches[:]:
if elem[1] == 0:
matches.remove(elem)
# sort by ids in order to remove duplicate ids for pics with less matches of the same product
matches = sorted(matches, key=lambda tup: tup[0])
# and remove possible product id duplicates
# that may appear from the match-making algorithm applied
# on different picture keypoints of the same product
s = set()
for elem in matches[:]:
if elem[0] in s:
matches.remove(elem)
else:
s.add(elem[0])
# sort by number of matches
matches = sorted(matches, key=lambda tup: tup[1])
matches.reverse()
# return the first number_of_results most matching
return [i for i in matches[:number_of_results]]