我和我的朋友正在為黑客馬拉松制作圖像識(shí)別的深度學(xué)習(xí)模型,我們不斷遇到這個(gè)問(wèn)題?;旧?,當(dāng)我運(yùn)行 run.py 進(jìn)行分析和成像時(shí),它會(huì)返回 sstable(壞幻數(shù))錯(cuò)誤。我們不知道為什么會(huì)這樣,也不知道該怎么辦。這是 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)調(diào)試時(shí),錯(cuò)誤顯示在行中l(wèi)oad_model。我們不知道如何修復(fù)它,歡迎任何幫助。
1 回答

慕絲7291255
TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊
好的,我知道為什么會(huì)發(fā)生這種情況。看來(lái)我必須在我的計(jì)算機(jī)上運(yùn)行該模型,以便它可以生成正確的變量和模型文件。
添加回答
舉報(bào)
0/150
提交
取消