Spaces:
Runtime error
Runtime error
#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= {'Burger King': 0, 'KFC': 1,'McDonalds': 2,'Other': 3,'Starbucks': 4,'Subway': 5} | |
HEIGHT,WIDTH=224,224 | |
NUM_CLASSES=6 | |
model=load_model('best_model.h5') | |
def classify_image(inp): | |
np.random.seed(143) | |
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.Textbox() | |
gr.Interface(fn=classify_image, inputs=image, outputs=label, title='Brand Logo Detection').launch(debug=False) | |