Update app.py
Browse files
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)
|
10 |
-
|
|
|
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()
|