ronalhung commited on
Commit
10245b8
·
verified ·
1 Parent(s): 6ccf269

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. app.py +36 -0
  3. best_model_normal.keras +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ best_model_normal.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import numpy as np
4
+ import tensorflow as tf
5
+ from tensorflow.keras.applications.mobilenet_v3 import preprocess_input
6
+
7
+ MODEL_PATH = "best_model_normal.keras"
8
+ CLASS_NAMES = [
9
+ "Leaf_Algal",
10
+ "Leaf_Blight",
11
+ "Leaf_Colletotrichum",
12
+ "Leaf_Healthy",
13
+ "Leaf_Phomopsis",
14
+ "Leaf_Rhizoctonia",
15
+ ]
16
+ IMG_SIZE = (224, 224)
17
+
18
+ model = tf.keras.models.load_model(MODEL_PATH)
19
+
20
+ def predict(img):
21
+ # img: numpy array HxWx3 (uint8)
22
+ x = tf.image.resize(img, IMG_SIZE)
23
+ x = tf.cast(x, tf.float32)
24
+ x = preprocess_input(x) # pipeline train
25
+ x = tf.expand_dims(x, 0) # (1,224,224,3)
26
+
27
+ prob = model.predict(x, verbose=0)[0]
28
+ return {CLASS_NAMES[i]: float(prob[i]) for i in range(len(CLASS_NAMES))}
29
+
30
+ demo = gr.Interface(
31
+ fn=predict,
32
+ inputs=gr.Image(type="numpy", label="Upload A Durian Leaf"),
33
+ outputs=gr.Label(num_top_classes=3, label="Result"),
34
+ title="Durian Leaf Disease Classification",
35
+ )
36
+ demo.launch()
best_model_normal.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5d56134ea28bfd388faae69243951883b653661ba189512ccefabbf4afb9c54
3
+ size 14164838