kamau1 commited on
Commit
7acea8d
·
1 Parent(s): fee53e3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow
3
+ import numpy
4
+ from PIL import Image
5
+
6
+ model_path = "Coralhealth.pb"
7
+ model = tf.saved_model.load(model_path)
8
+
9
+ classes = [ "bleached" , "healthy" , ]
10
+
11
+ def run(image_path):
12
+ img = Image.open(image_path).convert('RGB')
13
+ img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS)
14
+ inp_numpy = numpy.array(img)[None]
15
+ inp = tensorflow.constant(inp_numpy, dtype='float32')
16
+ class_scores = model(inp)[0].numpy()
17
+ return class_scores
18
+
19
+ title = "Trash Detector"
20
+ description = (
21
+ ""
22
+ )
23
+
24
+ examples = glob.glob("images/*.png")
25
+
26
+ interface = gr.Interface(
27
+ run,
28
+ inputs=[gr.components.Image(type="filepath")],
29
+ outputs="text",
30
+ title=title,
31
+ description=description,
32
+ examples=examples,
33
+ )
34
+
35
+ interface.queue().launch()