为了账号安全,请及时绑定邮箱和手机立即绑定

我怎样才能解决 not an sstable bad magic number 错误

我怎样才能解决 not an sstable bad magic number 错误

MMTTMM 2023-03-08 14:56:44
我和我的朋友正在为黑客马拉松制作图像识别的深度学习模型,我们不断遇到这个问题。基本上,当我运行 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。我们不知道如何修复它,欢迎任何帮助。
查看完整描述

1 回答

?
慕丝7291255

TA贡献1859条经验 获得超6个赞

好的,我知道为什么会发生这种情况。看来我必须在我的计算机上运行该模型,以便它可以生成正确的变量和模型文件。



查看完整回答
反对 回复 2023-03-08
  • 1 回答
  • 0 关注
  • 280 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信