Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,13 @@ model = tf.saved_model.load(model_path)
|
|
10 |
classes = [ "bleached" , "healthy" , ]
|
11 |
|
12 |
def run(image_path):
|
13 |
-
img = Image.open(
|
14 |
img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS)
|
15 |
-
inp_numpy =
|
16 |
-
inp =
|
17 |
class_scores = model(inp)[0].numpy()
|
18 |
-
|
|
|
19 |
|
20 |
title = "Trash Detector"
|
21 |
description = (
|
@@ -28,6 +29,7 @@ interface = gr.Interface(
|
|
28 |
run,
|
29 |
inputs=[gr.components.Image(type="filepath")],
|
30 |
outputs="text",
|
|
|
31 |
title=title,
|
32 |
description=description,
|
33 |
examples=examples,
|
|
|
10 |
classes = [ "bleached" , "healthy" , ]
|
11 |
|
12 |
def run(image_path):
|
13 |
+
img = Image.open(i).convert('RGB')
|
14 |
img = img.resize((300, 300 * img.size[1] // img.size[0]), Image.ANTIALIAS)
|
15 |
+
inp_numpy = np.array(img)[None]
|
16 |
+
inp = tf.constant(inp_numpy, dtype='float32')
|
17 |
class_scores = model(inp)[0].numpy()
|
18 |
+
state = classes[class_scores.argmax()]
|
19 |
+
return state
|
20 |
|
21 |
title = "Trash Detector"
|
22 |
description = (
|
|
|
29 |
run,
|
30 |
inputs=[gr.components.Image(type="filepath")],
|
31 |
outputs="text",
|
32 |
+
#outputs=gradio.outputs.Label(num_top_classes=3),
|
33 |
title=title,
|
34 |
description=description,
|
35 |
examples=examples,
|