Update app.py
Browse files
app.py
CHANGED
@@ -59,19 +59,20 @@ classnames = [
|
|
59 |
]
|
60 |
|
61 |
|
62 |
-
def predict(
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
pred =
|
68 |
-
|
|
|
69 |
return confidences
|
70 |
|
71 |
|
72 |
gr.Interface(
|
73 |
fn=predict,
|
74 |
-
inputs=gr.Image(
|
75 |
outputs=gr.Label(num_top_classes=5),
|
76 |
examples=[
|
77 |
"Dalbergia oliveri.JPG",
|
|
|
59 |
]
|
60 |
|
61 |
|
62 |
+
def predict(image):
|
63 |
+
img = tf.image.resize(image, (224, 224))
|
64 |
+
|
65 |
+
img = tf.cast(img, tf.float32) / 255.0
|
66 |
+
|
67 |
+
pred = model.predict(tf.expand_dims(img, axis=0))
|
68 |
+
|
69 |
+
confidences = {classnames[i]: float(pred[0][i]) for i in range(len(classnames))}
|
70 |
return confidences
|
71 |
|
72 |
|
73 |
gr.Interface(
|
74 |
fn=predict,
|
75 |
+
inputs=gr.Image(),
|
76 |
outputs=gr.Label(num_top_classes=5),
|
77 |
examples=[
|
78 |
"Dalbergia oliveri.JPG",
|