本文整理匯總了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]]