Spaces:
Sleeping
Sleeping
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() | |