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


Python Parallel.reverse方法代碼示例

本文整理匯總了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]]
開發者ID:AdinaPirjol,項目名稱:product-matchmaking,代碼行數:35,代碼來源:match.py


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