We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
def kmeans(box, k): #-------------------------------------------------------------# # 取出一共有多少框 #-------------------------------------------------------------# row = box.shape[0]
#-------------------------------------------------------------# # 每个框各个点的位置 #-------------------------------------------------------------# distance = np.empty((row, k)) #-------------------------------------------------------------# # 最后的聚类位置 #-------------------------------------------------------------# last_clu = np.zeros((row, )) np.random.seed() #-------------------------------------------------------------# # 随机选5个当聚类中心 #-------------------------------------------------------------# cluster = box[np.random.choice(row, k, replace = False)] iter = 0 while True: #-------------------------------------------------------------# # 计算当前框和先验框的宽高比例 #-------------------------------------------------------------# for i in range(row): distance[i] = 1 - cas_iou(box[i], cluster) #-------------------------------------------------------------# # 取出最小点 #-------------------------------------------------------------# near = np.argmin(distance, axis=1) if (last_clu == near).all(): break #-------------------------------------------------------------# # 求每一个类的中位点 #-------------------------------------------------------------# for j in range(k): cluster[j] = np.median( box[near == j],axis=0) last_clu = near if iter % 5 == 0: print('iter: {:d}. avg_iou:{:.2f}'.format(iter, avg_iou(box, cluster))) iter += 1 return cluster, near
大佬我按照 9个聚类中心的话,你这里说 # 随机选5个当聚类中心代码中if iter % 5 == 0:是不是要把5改为9,还是这个5是迭代聚类的次数?
The text was updated successfully, but these errors were encountered:
这只是print用的,和几个点没关
Sorry, something went wrong.
那这里如果要随机选择2个当聚类中心,是要修改这部分哪里的代码呢?求大佬指点
No branches or pull requests
def kmeans(box, k):
#-------------------------------------------------------------#
# 取出一共有多少框
#-------------------------------------------------------------#
row = box.shape[0]
大佬我按照 9个聚类中心的话,你这里说 # 随机选5个当聚类中心代码中if iter % 5 == 0:是不是要把5改为9,还是这个5是迭代聚类的次数?
The text was updated successfully, but these errors were encountered: