Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ import numpy as np
|
|
22 |
|
23 |
from keras.models import model_from_json
|
24 |
from keras.preprocessing import image
|
25 |
-
|
26 |
import heapq
|
27 |
|
28 |
file = open("focusondriving.json", 'r')
|
@@ -49,7 +49,7 @@ def predict_image(pic):
|
|
49 |
img = image.load_img(pic, target_size=(224, 224))
|
50 |
x = image.img_to_array(img)
|
51 |
x = np.expand_dims(x, axis=0)
|
52 |
-
|
53 |
preds = loaded_model.predict(x)
|
54 |
preds = list(preds[0])
|
55 |
|
|
|
22 |
|
23 |
from keras.models import model_from_json
|
24 |
from keras.preprocessing import image
|
25 |
+
from keras.applications.vgg16 import VGG16, preprocess_input
|
26 |
import heapq
|
27 |
|
28 |
file = open("focusondriving.json", 'r')
|
|
|
49 |
img = image.load_img(pic, target_size=(224, 224))
|
50 |
x = image.img_to_array(img)
|
51 |
x = np.expand_dims(x, axis=0)
|
52 |
+
x = preprocess_input(x)
|
53 |
preds = loaded_model.predict(x)
|
54 |
preds = list(preds[0])
|
55 |
|