使用真實世界的模型
太好了,Ivy 的照片已經可以給 ResNet50 使用了。影像儲存在 img_ready,現在看起來像這樣:
ResNet50 是在 Imagenet 資料集上訓練的模型,能分辨 1000 種不同的標記物體。ResNet50 是一個深度模型,具有 50 個層。你可以在 3D 中於此處查看它:here。
ResNet50 和 decode_predictions 已為你從 tensorflow.keras.applications.resnet50 匯入。
現在就用這個已訓練好的模型來找出 Ivy 是什麼犬種吧!
本練習屬於課程
Keras 深度學習入門
練習說明
- 實例化一個
ResNet50模型,將 weights 參數設為'imagenet'。 - 使用
model對已處理的影像進行預測。 - 使用
decode_predictions()解碼前 3 個預測結果。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Instantiate a ResNet50 model with 'imagenet' weights
model = ____(weights=____)
# Predict with ResNet50 on your already processed img
preds = ____.____(____)
# Decode the first 3 predictions
print('Predicted:', ____(____, top=____)[0])