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 | |
#os.environ['TF_KERAS'] = '1' | |
#os.environ['TF_ENABLE_ONEDNN_OPTS']='0' | |
labels=['Burger King', 'Subway', 'McDonalds', 'Starbucks', 'Other', 'KFC'] | |
HEIGHT,WIDTH=224,224 | |
model=load_model('best_model.h5') | |
NUM_CLASSES=6 | |
def classify_image(inp): | |
inp = inp.reshape((-1, HEIGHT,WIDTH, 3)) | |
inp = tf.keras.applications.nasnet.preprocess_input(inp) | |
prediction = model.predict(inp).flatten() | |
return {labels[i]: float(prediction[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) | |