0

I am trying to fit images file to an autokeras image classifier. Code I am using is given below,

import autokeras as ak
import os
import numpy as np
from sklearn.model_selection import train_test_split
path= '/Users/Downloads/business_cards/Canon/'
X_data = os.listdir(path)
training, test = train_test_split(X_data, test_size=0.20, random_state=42)
x= np.array([training])
print(x.shape)
clf = ak.ImageClassifier(overwrite=True, max_trials=1)
clf.fit(x,epochs=1)

But it gives me the following error, AttributeError: 'NoneType' object has no attribute 'shape'

Could someone please help me with this.

  • 1
    Could you please specify the line where you got the error? – abdou_dev Nov 30 '21 at 22:42
  • seems like your not loading the data in properly? try to follow the documentation here: https://autokeras.com/tutorial/image_classification/ – Alexei Vladimirovich Kashenko Nov 30 '21 at 22:42
  • You have a problem with the variable `X if I'm correct , so `np.array([training])` give Null value , try to see the output of `print(training)` – abdou_dev Nov 30 '21 at 22:46
  • @ abdou_dev, thank you for replying but training is my list of images that is in the following format:['094.jpg', '021.jpg','089.jpg','065.jpg'.........] and I am trying to fit this data to my classifier. – swetha sreedhar Nov 30 '21 at 23:57
  • @abdou_dev, clf.fit(x, epochs =1) gives the error. – swetha sreedhar Dec 01 '21 at 00:06
  • Your error is in `x.shape` , because x is null , please try to `print(np.array([training]))` and see the output – abdou_dev Dec 01 '21 at 10:24
  • @abdou_dev, No, x.shape does not give null value it gives (1,80) value. My 'x' is ndarray of images, [['094.jpg','021.jpg'......]], even after I remove the brackets and give np.array(training), I still get the same error. – swetha sreedhar Dec 01 '21 at 15:10
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Dec 05 '21 at 17:44

0 Answers0