The reshape for input to self.clf_model.predict() line 98 is wrong. The p array is reshape into a (x,4800) array instead of a (x,40,40,3)