Spaces:
Sleeping
Sleeping
import gradio as gr | |
import tensorflow as tf | |
import numpy | |
from PIL import Image | |
model_path = "Coralhealth.pb" | |
model = tf.saved_model.load(model_path) | |
classes = [ "bleached" , "healthy" , ] | |
def run(image_path): | |
img = Image.open(image_path).convert('RGB') | |
img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS) | |
inp_numpy = numpy.array(img)[None] | |
inp = tensorflow.constant(inp_numpy, dtype='float32') | |
class_scores = model(inp)[0].numpy() | |
return class_scores | |
title = "Trash Detector" | |
description = ( | |
"" | |
) | |
examples = glob.glob("images/*.png") | |
interface = gr.Interface( | |
run, | |
inputs=[gr.components.Image(type="filepath")], | |
outputs="text", | |
title=title, | |
description=description, | |
examples=examples, | |
) | |
interface.queue().launch() | |