File size: 797 Bytes
7acea8d
2319edf
7acea8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
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()