Sa-m's picture
Update app.py
4bfddf6
raw
history blame
736 Bytes
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 os
#os.environ['TF_KERAS'] = '1'
#os.environ['TF_ENABLE_ONEDNN_OPTS']='0'
model=load_model('best_model_76.h5')
def classify_image(inp):
inp = inp.reshape((-1, IMG_SIZE, IMG_SIZE, 3))
#inp = tf.keras.applications.vgg16.preprocess_input(inp)
prediction = model.predict(inp).flatten()
return {labels[i]: float(prediction[i]) for i in range(NUM_CLASSES)}
image = gr.inputs.Image(shape=(IMG_SIZE, IMG_SIZE),label='Input')
label = gr.outputs.Label(num_top_classes=2)
gr.Interface(fn=classify_image, inputs=image, outputs=label, title='Brand Logo Detection').launch(debug=False)