我和我的朋友正在为黑客马拉松制作图像识别的深度学习模型,我们不断遇到这个问题。基本上,当我运行 run.py 进行分析和成像时,它会返回 sstable(坏幻数)错误。我们不知道为什么会这样,也不知道该怎么办。这是 run.py: import os, gcfrom skimage import ioimport globimport pandas as pdimport globimport tensorflow as tffrom tensorflow import kerasfrom keras.preprocessing import imagefrom tensorflow.keras.models import Sequential, save_model, load_modelimport matplotlib.pyplot as pltimport numpy as npfrom skimage import transformfrom keras.optimizers import Adamfrom keras.applications import mobilenet_v2from PIL import Imagepath = []for file in os.listdir("./media_cdn"): path.append(file)print(path)filepath = './saved_model'model = load_model(filepath, custom_objects= None, compile = False)loss = 'CategoricalCrossentropy'optimizer = Adam(lr=1e-5)metrics = ['binary_accuracy']model.compile(optimizer=optimizer, loss=loss, metrics=metrics)def load(filename):np_image = Image.open("./media_cdn/" + filename)np_image = np.array(np_image).astype('float32')/255np_image = transform.resize(np_image, (244, 244, 3))np_image = np.expand_dims(np_image, axis=0)return np_imagenew_image = load(path[0])print(new_image.shape)new_model = keras.Sequential([model])new_model.load_weights('./model_weights')prediction = new_model.predict_classes(new_image)classes = np.argmax(prediction, axis = -1)print(classes)print('This is the Diagnosis:')if classes == 0: print('MELANOMA')if classes == 1: print('Melanocytic Nevus')if classes == 2: print('Basal Cell Carcinoma')if classes == 3: print('Arctinic Keratosis')if classes == 4: print('Benign Keratosis')if classes == 5: print('Dermatofibroma')if classes == 6: print('Vascular Lesion')if classes == 7: print('Squamous Cell Carcinoma')if classes == 8: print(['Unknown', 'BCC', 'AK', 'BKL', 'DF', 'VASC', 'SCC', 'UNK'])classes = np.argmax(prediction, axis = 1)print(classes)调试时,错误显示在行中load_model。我们不知道如何修复它,欢迎任何帮助。
添加回答
举报
0/150
提交
取消