File size: 717 Bytes
52d93bc
be1db53
 
 
52d93bc
df7b1ef
 
 
be1db53
 
f2151cc
26e9ce9
2af56c0
0ccd851
 
be1db53
 
 
2af56c0
be1db53
 
e24521d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
import tensorflow as tf
import numpy as np
import requests

labels = ["missing"] * 36
with open('labels.txt','r') as f:
  labels = f.read().splitlines()

def classify_image(inp):
  model = tf.keras.models.load_model('saved_model')
  inp = inp.resize((480,480))
  inp = np.array(inp)
  inp = np.reshape(inp,(-1, 480, 480, 3)).astype(np.float32)
  inp = np.divide(inp,255.0)
  prediction = model.predict(inp).flatten()
  return {labels[i]: float(prediction[i]) for i in range(36)}

image = gr.inputs.Image(type='pil')
label = gr.outputs.Label(num_top_classes=3)

gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True, theme = "grass", examples = [["test.jpg"]]).launch()