File size: 774 Bytes
08e4872
159fb0f
 
 
 
e845a5d
0764d7b
1956924
 
 
303a695
159fb0f
a1507f1
c47223a
a1507f1
 
c47223a
 
159fb0f
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
#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
from tensorflow.keras.applications.inception_resnet_v2 import InceptionResNetV2

#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, 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)