File size: 816 Bytes
5ce239b
159fb0f
 
 
 
6f7f6f4
6d4bbd5
765551f
e630870
ff37d75
e630870
d45c904
e630870
159fb0f
eb16681
74a719c
eb16681
2113720
74a719c
 
159fb0f
eb16681
 
74a719c
26a7280
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
#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
from tensorflow.keras.layers import *

labels= {'Subway': 0, 'Starbucks': 1,'McDonalds': 2,'Burger King': 3,'KFC': 4,'Other': 5}
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)