panik commited on
Commit
629fdc8
1 Parent(s): 85cae6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -2,12 +2,14 @@ import gradio as gr
2
  from keras.applications.vgg16 import VGG16
3
  from keras.preprocessing import image
4
  from keras.applications.vgg16 import preprocess_input
 
5
  import numpy as np
6
 
7
  def predict_image(img):
8
  img_4d = img.reshape(-1,224,224,3)
9
- prediction = model.predict(img_4d)[0]
10
- return {class_names[i]: float(prediction[i]) for i in range(5)}
 
11
 
12
  model = VGG16()
13
  model.summary()
 
2
  from keras.applications.vgg16 import VGG16
3
  from keras.preprocessing import image
4
  from keras.applications.vgg16 import preprocess_input
5
+ from keras.applications.vgg16 import decode_predictions
6
  import numpy as np
7
 
8
  def predict_image(img):
9
  img_4d = img.reshape(-1,224,224,3)
10
+ prediction = model.predict(img_4d)
11
+ prediction_results = decode_predictions(prediction, top = 5)
12
+ return { prediction_results[0][i][1]: float(prediction_results[0][i][2]) for i in range(5) }
13
 
14
  model = VGG16()
15
  model.summary()