imeesam commited on
Commit
32288b8
·
verified ·
1 Parent(s): 361992f

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +22 -0
  2. leaf_model.tflite +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +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()
leaf_model.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b796a2ea5756e8a3372ee107d4cd382de937c341cf1d7dddd3823e084a959bb7
3
+ size 9520748
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==4.27.0
2
+ tensorflow==2.15.0
3
+ numpy
4
+ Pillow