Ask Your Question
0

SVM: AttributeError Image Instance has no attribute 'resolution'

asked 2012-08-10 08:50:47 -0500

anonymous user

Anonymous

updated 2012-08-10 08:52:24 -0500

I am running Windows Vista with latest SimpleCV version. I tried to test the latest MLTestSuite, in particular the SVMCassifier with my own local image dataset. Folders in my dataset are structured exactly as .zip from github. The system works almost fine, BUT I get an AttributeError Image Instance has no attribute 'resolution'

Can somebody give me a tip? Thanks!

from SimpleCV import *

img_beach = "Users/Arenzky/Desktop/img_dirs/supervised/beach" 
img_pier = "Users/Arenzky/Desktop/img_dirs/supervised/pier"
img_port_area = "Users/Arenzky/Desktop/img_dirs/supervised/port_area"
img_sea = "Users/Arenzky/Desktop/img_dirs/supervised/sea"

testdataset = ['Users/Arenzky/Desktop/img_dirs/unsupervised/hotspot2',
'Users/Arenzky/Desktop/img_dirs/unsupervised/hotspot3']

display = Display(resolution = (w,h))

hue = HueHistogramFeatureExtractor(mNBins=16)
edge = EdgeHistogramFeatureExtractor()
bof = BOFFeatureExtractor()
haar = HaarLikeFeatureExtractor()
morph = MorphologyFeatureExtractor()

supervised = "/Users/Arenzky/Desktop/img_dirs/supervised/"          #load supervised files
unsupervised = "/Users/Arenzky/Desktop/img_dirs/unsupervised/"      
beach_path = supervised+"beach/"
pier_path = supervised+"pier/"
port_area_path = supervised+"port_area/"
sea_path = supervised +"sea/"

hotspot2_path = unsupervised+"hotspot2/"
hotspot3_path = unsupervised+"hotspot3/"

print('SVMPoly')
#Set up am SVM with a poly kernel
extractors = [hue]
path = [beach_path,pier_path,port_area_path,sea_path]
classes = ['beach','pier','port_area','sea']
props ={
        'KernelType':'RBF', #default is a RBF Kernel
        'SVMType':'C', #default is C
        'nu':None, # NU for SVM NU
        'c':None, #C for SVM C - the slack variable
        'degree':3, #degree for poly kernels - defaults to 3
        'coef':None, #coef for Poly/Sigmoid defaults to 0
        'gamma':None, #kernel param for poly/rbf/sigma - default is 1/#samples
    }
print('Train')
classifierSVMP = SVMClassifier(extractors,props)
classifierSVMP.train(path,classes,disp=display,subset=n) #train
print('Test')
[pos,neg,confuse] = classifierSVMP.test(path,classes,disp=display,subset=n)
files = []
for ext in IMAGE_FORMATS:
        files.extend(glob.glob( os.path.join(path[0], ext)))
for i in range(10):
        img = Image(files[i])
        cname = classifierSVMP.classify(img)
        print(files[i]+' -> '+cname)
classifierSVMP.save('PolySVM.pkl')
print('Reloading from file')
testSVM = SVMClassifier.load('PolySVM.pkl')
#testSVM.setFeatureExtractors(extractors)
files = glob.glob( os.path.join(path[0], '*.jpg'))
for i in range(10):
        img = Image(files[i])
        cname = testSVM.classify(img)
        print(files[i]+' -> '+cname)



AttributeError: Image Instance has no attribute 'resolution'
edit retag flag offensive close merge delete

6 Answers

Sort by ยป oldest newest most voted
1

answered 2012-08-10 09:12:30 -0500

kscottz gravatar image

Just a guess, is pygame installed? Also did you try just d = Display((640,480))?

edit flag offensive delete link more
0

answered 2012-08-10 11:07:06 -0500

Arenzky gravatar image

THANKS, The script runs smooth now and I am getting a results matrix as proposed by your test Suite. This was the most important task for me so far.

The display appears but remains black, there is no "slideshow" going on.

edit flag offensive delete link more
0

answered 2012-08-10 09:49:18 -0500

Arenzky gravatar image

pygame is installed and d = Display((640,480)) attempted; still the AttributeError. The script runs smooth, opens the list of images, e.g.... Opening file:/./image1.jpg and then the AttributeError

edit flag offensive delete link more
0

answered 2012-08-10 09:53:49 -0500

kscottz gravatar image

Also what happens when you try to create a display in the shell?

edit flag offensive delete link more
0

answered 2012-08-10 10:15:47 -0500

Arenzky gravatar image

Now I am using the script from http://pydoc.net/SimpleCV/1.2/SimpleCV.tests.MLTestSuite

This link mentioned on this help page does not work anymore since a few days... https://github.com/ingenuitas/SimpleCV/blob/master/SimpleCV/tests/MLTestSuite.py

edit flag offensive delete link more
0

answered 2012-08-10 09:53:08 -0500

kscottz gravatar image

I just tried this on my Mac with no problems. Are you running from the 1.2 release or from straight from the repo master branch?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-10 08:50:47 -0500

Seen: 716 times

Last updated: Aug 10 '12