Я пытаюсь использовать автокера для модели классификации изображений, когда подгоняю свои данные, эта ошибка возникает
DATADIR = r"C:\Users\angesu\Desktop\DOCUMENT_DATA"
CATEGORIES = ["resume","transcript","certificate"]
IMG_SIZE = 250
for category in CATEGORIES :
path = os.path.join(DATADIR, category)
for img in os.listdir(path):
img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_GRAYSCALE)
training_data = []
def create_training_data():
for category in CATEGORIES :
path = os.path.join(DATADIR, category)
class_num = CATEGORIES.index(category)
for img in os.listdir(path):
try :
img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
training_data.append([new_array, class_num])
except Exception as e:
pass
create_training_data()
random.shuffle(training_data)
X = [] #features
y = [] #labels
for features, label in training_data:
X.append(features)
y.append(label)
X = np.asarray(X).reshape(-1, IMG_SIZE, IMG_SIZE, 1)
clf = ak.ImageClassifier(max_trials=10)
clf.fit(X,y,validation_split=0.1)
def prepare(file):
IMG_SIZE = 250
img_array = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
path = r"C:\Users\angesu\Downloads\Garn-Certificate-4.jpg"
predicted_y = clf.predict(prepare(path))
print(clf.evaluate(test_set))
Я не знаю, как решить эту проблему, я пытаюсь использовать tf.data.Dataset .from_tensor_slices (), но эта ошибка все еще показывает, что я гуглю эту ошибку, но ничего не понимаю. Ошибка в clf.fit (X, y, validation_split = 0.1)
Сообщение об ошибке
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-11-b327f1f23808> in <module>
1 clf = ak.ImageClassifier(max_trials=10)
2 # Feed the tensorflow Dataset to the classifier.
----> 3 clf.fit(X,Y,validation_split=0.1)
4 # Predict with the best model.
5
C:\ProgramData\Anaconda3\lib\site-packages\autokeras\task.py in fit(self, x, y, epochs, callbacks, validation_split, validation_data, **kwargs)
114 validation_split=validation_split,
115 validation_data=validation_data,
--> 116 **kwargs)
117
118
C:\ProgramData\Anaconda3\lib\site-packages\autokeras\auto_model.py in fit(self, x, y, epochs, callbacks, validation_split, validation_data, **kwargs)
156 y=y,
157 validation_data=validation_data,
--> 158 validation_split=validation_split)
159
160 # Initialize the hyper_graph.
C:\ProgramData\Anaconda3\lib\site-packages\autokeras\auto_model.py in _prepare_data(self, x, y, validation_data, validation_split)
259 if validation_data is None and validation_split:
260 self._split_dataset = True
--> 261 dataset, validation_data = utils.split_dataset(dataset, validation_split)
262 return dataset, validation_data
263
C:\ProgramData\Anaconda3\lib\site-packages\autokeras\utils.py in split_dataset(dataset, validation_split)
64 A tuple of two tf.data.Dataset. The training set and the validation set.
65 """
---> 66 num_instances = dataset.reduce(np.int64(0), lambda x, _: x + 1).numpy()
67 if num_instances < 2:
68 raise ValueError('The dataset should at least contain 2 '
AttributeError: 'Tensor' object has no attribute 'numpy'