I would to print the images on index i
but I get an error of only integer scalar arrays can be converted to a scalar index
. How can I convert I
to int for each iteration
I have tried replacing images[i]
with images[n]
it worked but not the result I want.
c = [1 1 1 0 1 2 2 3 4 1 3]
#c here is list of cluster labels obtained after Affinity propagation
num_clusters = len(set(c))
images = os.listdir(DIR_NAME)
for n in range(num_clusters):
print("\n --- Images from cluster #%d ---" % n)
for i in np.argwhere(c == n):
if i != -1:
print("Image %s" % images[i])
I expect the output to be the name of the image, but I instead get TypeError: only integer scalar arrays can be converted to a scalar index
that is because i
is of type numpy.ndarray