Autokeras: AttributeError: 'ImageClassifier' object has no attribute 'load_searcher' I CANT SOLVE IT BY UPDATE MY local AUTO-KERAS

Created on 30 Nov 2018  路  3Comments  路  Source: keras-team/autokeras

This is the error report:

Traceback (most recent call last):
File "test3.py", line 58, in
clf.load_searcher().load_best_model().produce_keras_model().save(MODEL_DIR)
AttributeError: 'ImageClassifier' object has no attribute 'load_searcher'

This is my code:

from autokeras.image_supervised import load_image_dataset, ImageClassifier
from keras.models import load_model
from keras.utils import plot_model
from keras.preprocessing.image import load_img, img_to_array
import numpy as np

TRAIN_CSV_DIR = '/home/kidrival1/Downloads/re/train_labels.csv'
TRAIN_IMG_DIR = '/home/kidrival1/Downloads/re/train_output'
TEST_CSV_DIR = '/home/kidrival1/Downloads/re/test_labels.csv'
TEST_IMG_DIR = '/home/kidrival1/Downloads/re/test_output'

PREDICT_IMG_PATH = '/home/kidrival1/Downloads/re/test_output/719.jpg'

MODEL_DIR = '/home/kidrival1/Downloads/re/my_model.h5'
MODEL_PNG = '/home/kidrival1/Downloads/re/model.png'
IMAGE_SIZE = 28

if __name__ == '__main__':

train_data, train_labels = load_image_dataset(csv_file_path=TRAIN_CSV_DIR, images_path=TRAIN_IMG_DIR)
test_data, test_labels = load_image_dataset(csv_file_path=TEST_CSV_DIR, images_path=TEST_IMG_DIR)

train_data = train_data.astype('float32') / 255
test_data = test_data.astype('float32') / 255
print("train data shape:", train_data.shape)

clf = ImageClassifier(verbose=True)

clf.fit(train_data, train_labels, time_limit=5 * 60)

clf.final_fit(train_data, train_labels, test_data, test_labels, retrain=True)

y = clf.evaluate(test_data, test_labels)
print("evaluate:", y)

img = load_img(PREDICT_IMG_PATH)
x = img_to_array(img)
x = x.astype('float32') / 255
x = np.reshape(x, (1, IMAGE_SIZE, IMAGE_SIZE, 3))
print("x shape:", x.shape)

y = clf.predict(x)
print("predict:", y)

clf.load_searcher().load_best_model().produce_keras_model().save(MODEL_DIR)

model = load_model(MODEL_DIR)

plot_model(model, to_file=MODEL_PNG)

Setup Details

Include the details about the versions of:

Most helpful comment

I would try clf.export_keras_model(MODEL_DIR)

All 3 comments

I would try clf.export_keras_model(MODEL_DIR)

I would try clf.export_keras_model(MODEL_DIR)

Thank you

I would try clf.export_keras_model(MODEL_DIR)

I have trouble loading the saved function using keras load_model function.
It said OSError: Unable to open file (file signature not found)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

max1563 picture max1563  路  4Comments

ikscapes picture ikscapes  路  3Comments

touching-foots-huskie picture touching-foots-huskie  路  4Comments

GagaLeung picture GagaLeung  路  4Comments

zhangjinyangnwpu picture zhangjinyangnwpu  路  4Comments