Spaces:
Runtime error
Runtime error
File size: 909 Bytes
08e4872 159fb0f f7d5b45 e845a5d c1c9c3a 742b795 01a716c 6040ac9 159fb0f c1c9c3a a1507f1 c47223a a1507f1 c1c9c3a 1f1c04d c1c9c3a 962146a c1c9c3a 159fb0f c1c9c3a a1507f1 c47223a 4bfddf6 159fb0f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#import tensorflow_addons as tfa
import gradio as gr
import tensorflow as tf
import numpy as np
from tensorflow.keras.models import load_model
import tensorflow_addons as tfa
import os
import numpy as np
labels= { 'Subway': 0,'Starbucks': 1,'McDonalds': 2,'Burger King': 3,'KFC': 4,'Other': 5}
HEIGHT,WIDTH=224,224
NUM_CLASSES=6
model=load_model('best_model.h5')
def classify_image(inp):
inp = inp.reshape((-1, HEIGHT,WIDTH, 3))
inp = tf.keras.applications.nasnet.preprocess_input(inp)
prediction = model.predict(inp)
label = dict((v,k) for k,v in labels.items())
predicted_class_indices=np.argmax(prediction,axis=1)
return {labels[i]: float(predicted_class_indices[i]) for i in range(NUM_CLASSES)}
image = gr.Image(shape=(HEIGHT,WIDTH),label='Input')
label = gr.Label()
gr.Interface(fn=classify_image, inputs=image, outputs=label, title='Brand Logo Detection').launch(debug=False)
|