0

I am trying to ran the following code, and I get an AttributeError: 'module' object has no attribute 'hcluster', raised in the last line.

I am running in Mountain Lion, I use pip and homebrew, and hcluster is in PYTHONPATH=/usr/local/lib/python2.7/site-packages.

Any idea what can be going wrong? Thanks.

import os 
import hcluster
from numpy import *
from PIL import Image
# create a list of images
path = 'data/flickr-sunsets-small'
imlist = [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')]
# extract feature vector (8 bins per color channel)
features = zeros([len(imlist), 512])
for i,f in enumerate(imlist):
    im = array(Image.open(f))
    # multi-dimensional histogram
    h,edges = histogramdd(im.reshape(-1,3),8,normed=True,range=[(0,255),(0,255),(0,255)]) 
    features[i] = h.flatten()
tree = hcluster.hcluster(features)

1 Answer 1

1

This error means that Python cannot find the function/class hcluster in the module hcluster, so when you do tree = hcluster.hcluster(features) it complains.

I'm not familiar with this module, but I had a quick look at this it, and it lists a function called fcluster, but no hcluster.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.