snlpatel001213 / algorithmia Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Hello, I'm currently working on making the algorithm working, still I have an issue at the end of the program about the predict_classes function in the last input.
I didn't change anything to the original code and imported all the modules specified in the requirement.
This is so the last input of the program.
folderName = "imdb_crop_resized128*128"
fileNames = glob.glob(folderName+"/*.jpg")
NumberOfFileToBetested = 500
x_batch,y_batch = turnToNumpy(fileNames[:NumberOfFileToBetested])
predictedAGE = model.predict_classes(x_batch)
realAGE = []
imagesCount = 0
os.mkdir('testImages')
for eachFilename in fileNames[:NumberOfFileToBetested]:
realAGE = getRealAge(eachFilename)
#saving Images
x = load_image(eachFilename)
x = x.reshape(x.shape[1],x.shape[2],x.shape[0])
renamedImage = "testImages/"+str(realAGE)+"_"+str(predictedAGE[imagesCount])+".jpg"
imsave(renamedImage, x)
imagesCount = imagesCount + 1
And there is the error specified. I don't know how to resolve this.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-17-7f653efe2f7b> in <module>()
7 x_batch,y_batch = turnToNumpy(fileNames[:NumberOfFileToBetested])
8
----> 9 predictedAGE = model.predict_classes(x_batch)
10
11 realAGE = []
~/Téléchargements/anaconda3/lib/python3.6/site-packages/keras/models.py in predict_classes(self, x, batch_size, verbose)
824 A numpy array of class predictions.
825 '''
--> 826 proba = self.predict(x, batch_size=batch_size, verbose=verbose)
827 if proba.shape[-1] > 1:
828 return proba.argmax(axis=-1)
~/Téléchargements/anaconda3/lib/python3.6/site-packages/keras/models.py in predict(self, x, batch_size, verbose)
714 if self.model is None:
715 self.build()
--> 716 return self.model.predict(x, batch_size=batch_size, verbose=verbose)
717
718 def predict_on_batch(self, x):
~/Téléchargements/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in predict(self, x, batch_size, verbose)
1199 x = standardize_input_data(x, self.input_names,
1200 self.internal_input_shapes,
-> 1201 check_batch_dim=False)
1202 if self.stateful:
1203 if x[0].shape[0] > batch_size and x[0].shape[0] % batch_size != 0:
~/Téléchargements/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in standardize_input_data(data, names, shapes, check_batch_dim, exception_prefix)
99 ' to have ' + str(len(shapes[i])) +
100 ' dimensions, but got array with shape ' +
--> 101 str(array.shape))
102 for j, (dim, ref_dim) in enumerate(zip(array.shape, shapes[i])):
103 if not j and not check_batch_dim:
ValueError: Error when checking : expected zeropadding2d_input_1 to have 4 dimensions, but got array with shape (0, 1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.