**ModuleNotFoundError: No module named 'keras.applications.vgg16'**がでる
・kerasのアプリケーションを読み込んでくれなくなった。
・Spyderを入れなおしてみたが解決せず。
・昨日までは普通に動いてくれていた。
どなたか読み込ませに行く方法わかりませんか?理由を教えてもらえませんか?
Python3
1from keras.applications.vgg16 import VGG16, preprocess_input, decode_predictions 2from keras.preprocessing import image 3import requests 4import numpy as np 5model = VGG16(include_top=True, weights='imagenet', input_tensor=None, input_shape=None) 6 7 8def download_img(url, file_name): 9 r = requests.get(url, stream=True) 10 if r.status_code == 200: 11 with open(file_name, 'wb') as f: 12 f.write(r.content) 13 14 15if __name__ == '__main__': 16 url = 'https://www.nomooo.jp/wp-content/uploads/2018/01/pixta_16804929_M.jpg' 17 file_name = 'beer.jpg' 18 download_img(url, file_name) 19 img = image.load_img(file_name, target_size=(224, 224)) 20 21 ary = image.img_to_array(img) 22 23 ary = np.expand_dims(ary, axis=0) 24 25 preds = model.predict(preprocess_input(ary)) 26 results = decode_predictions(preds, top=5)[0] 27 for result in results: 28 print(result)
回答2件
あなたの回答
tips
プレビュー