imeesam commited on
Commit
68a7434
·
verified ·
1 Parent(s): c629be9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -1,22 +1,22 @@
1
- import gradio as gr
2
- import tensorflow as tf
3
- import numpy as np
4
- from PIL import Image
5
-
6
- interpreter = tf.lite.Interpreter(model_path="leaf_model.tflite")
7
- interpreter.allocate_tensors()
8
- input_details = interpreter.get_input_details()
9
- output_details = interpreter.get_output_details()
10
-
11
- def classify(image):
12
- img = image.resize((224, 224)).convert("RGB")
13
- img_array = np.array(img) / 255.0
14
- img_array = np.expand_dims(img_array, axis=0).astype(np.float32)
15
-
16
- interpreter.set_tensor(input_details[0]['index'], img_array)
17
- interpreter.invoke()
18
- output = interpreter.get_tensor(output_details[0]['index'])[0][0]
19
- return "Unhealthy" if output > 0.5 else "Healthy"
20
-
21
- iface = gr.Interface(fn=classify, inputs=gr.Image(type="pil"), outputs="text")
22
- iface.launch()
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ interpreter = tf.lite.Interpreter(model_path="leaf_model_85_percent.tflite")
7
+ interpreter.allocate_tensors()
8
+ input_details = interpreter.get_input_details()
9
+ output_details = interpreter.get_output_details()
10
+
11
+ def classify(image):
12
+ img = image.resize((224, 224)).convert("RGB")
13
+ img_array = np.array(img) / 255.0
14
+ img_array = np.expand_dims(img_array, axis=0).astype(np.float32)
15
+
16
+ interpreter.set_tensor(input_details[0]['index'], img_array)
17
+ interpreter.invoke()
18
+ output = interpreter.get_tensor(output_details[0]['index'])[0][0]
19
+ return "Unhealthy" if output > 0.45 else "Healthy"
20
+
21
+ iface = gr.Interface(fn=classify, inputs=gr.Image(type="pil"), outputs="text")
22
+ iface.launch()