Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,22 +5,26 @@ import numpy as np
|
|
5 |
from tensorflow.keras.models import load_model
|
6 |
import tensorflow_addons as tfa
|
7 |
import os
|
8 |
-
|
9 |
-
|
10 |
-
import datetime, os
|
11 |
|
12 |
-
labels= {
|
13 |
HEIGHT,WIDTH=224,224
|
14 |
-
model=load_model('best_model.h5')
|
15 |
NUM_CLASSES=6
|
|
|
16 |
|
|
|
17 |
|
18 |
def classify_image(inp):
|
19 |
inp = inp.reshape((-1, HEIGHT,WIDTH, 3))
|
20 |
-
|
21 |
-
prediction = model.predict(inp)
|
22 |
-
|
|
|
|
|
|
|
23 |
|
|
|
24 |
image = gr.Image(shape=(HEIGHT,WIDTH),label='Input')
|
25 |
label = gr.Label()
|
26 |
|
|
|
5 |
from tensorflow.keras.models import load_model
|
6 |
import tensorflow_addons as tfa
|
7 |
import os
|
8 |
+
import numpy as np
|
9 |
+
|
|
|
10 |
|
11 |
+
labels= { 0:, 'Starbucks': 1,'McDonalds': 2,'Burger King': 3,'KFC': 4,'Other': 5}
|
12 |
HEIGHT,WIDTH=224,224
|
|
|
13 |
NUM_CLASSES=6
|
14 |
+
categories= ('Starbucks','McDonalds','Burger King','KFC','Other')
|
15 |
|
16 |
+
model=load_model('best_model.h5')
|
17 |
|
18 |
def classify_image(inp):
|
19 |
inp = inp.reshape((-1, HEIGHT,WIDTH, 3))
|
20 |
+
inp = tf.keras.applications.nasnet.preprocess_input(inp)
|
21 |
+
prediction = model.predict(inp)
|
22 |
+
labels = dict((v,k) for k,v in labels.items())
|
23 |
+
predicted_class_indices=np.argmax(prediction,axis=1)
|
24 |
+
return {labels[i]: float(predicted_class_indices[i]) for i in range(NUM_CLASSES)}
|
25 |
+
|
26 |
|
27 |
+
|
28 |
image = gr.Image(shape=(HEIGHT,WIDTH),label='Input')
|
29 |
label = gr.Label()
|
30 |
|