PPAL icon indicating copy to clipboard operation
PPAL copied to clipboard

I use my dataset, when run the diversity_sampler, it encounter "assert len(cluster_i) >= 1" problem

Open syyxtl opened this issue 2 years ago • 6 comments

image image

syyxtl avatar Nov 29 '22 07:11 syyxtl

Hi, sorry for the late reply. This problem emerges when an image is assigned to more than one centroid, which is often caused by problems in distance computing. Could you please check the computed image distances?

ChenhongyiYang avatar Jan 12 '23 11:01 ChenhongyiYang

I also have the problem when I use my dataset, please tell me how can I do if I know the image distance

BroadswordZhang avatar Feb 23 '23 03:02 BroadswordZhang

image image Hi, I also want to train my own dataset, can you tell me what changes you made to train your own dataset

dust-removal avatar Jul 04 '23 12:07 dust-removal

@ChenhongyiYang I also faced this error while training on COCO.

sharat29ag avatar Sep 27 '23 05:09 sharat29ag

@ChenhongyiYang I also faced this error while training on my dataset.

shiyuanyu123 avatar Apr 10 '24 08:04 shiyuanyu123

Try with that code

@staticmethod
def kmeans(dis_matrix, K, n_iter=100):
    N = dis_matrix.shape[0]
    centroids = DiversitySampler.k_centroid_greedy(dis_matrix, K)
    data_indices = np.arange(N)

    assign_dis_records = []
    for _ in range(n_iter):
        centroid_dis = dis_matrix[:, centroids]
        cluster_assign = np.argmin(centroid_dis, axis=1)
        assign_dis = centroid_dis.min(axis=1).sum()
        assign_dis_records.append(assign_dis)

        new_centroids = []
        for i in range(K):
            cluster_i = data_indices[cluster_assign == i]
            if len(cluster_i) == 0:
                new_centroid_i = np.random.choice(data_indices)
            else:
                dis_mat_i = dis_matrix[cluster_i][:, cluster_i]
                new_centroid_i = cluster_i[np.argmin(dis_mat_i.sum(axis=1))]
            new_centroids.append(new_centroid_i)
        centroids = np.array(new_centroids)
    return centroids.tolist()

Parkkkkk avatar Jun 11 '24 06:06 Parkkkkk