sdqp commited on
Commit
1a2af9c
·
verified ·
1 Parent(s): 9ebeba0

Upload 7 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ 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
+ examples/bercak_coklat/Ex[[:space:]]brownSpot.jpg filter=lfs diff=lfs merge=lfs -text
37
+ examples/Hispa/IMG_20190420_194642.jpg filter=lfs diff=lfs merge=lfs -text
38
+ MyResNet101Model_final.keras filter=lfs diff=lfs merge=lfs -text
MyResNet101Model_final.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd162f759e74edc39e7c93124150529c08f1c159fef79b1355d31897db01ecb5
3
+ size 232818380
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pathlib
3
+ import random
4
+ import tensorflow as tf
5
+ from PIL import Image
6
+ from timeit import default_timer as timer
7
+ from keras.models import load_model
8
+
9
+ # Load the model
10
+ model = load_model('MyResNet101Model_final.keras')
11
+
12
+ # Define label mappings
13
+ label2id = {'Hispa': 0, 'Bercak Coklat': 1, 'Blast Daun': 2, 'Sehat': 3}
14
+ class_names = list(label2id.keys())
15
+
16
+ def predict(img):
17
+ start = timer()
18
+
19
+ img = img.resize((224, 224))
20
+ img_aug = tf.keras.layers.Rescaling(1., input_shape=(224, 224, 3))
21
+ output = tf.expand_dims(img_aug(img), 0)
22
+ pred_prob = tf.nn.softmax(model.predict(output))
23
+ pred_dict = {class_names[i]:float(tf.squeeze(pred_prob)[i]) for i in range(len(class_names))}
24
+
25
+ pred_time = round(timer() - start, 5)
26
+
27
+ return pred_dict, pred_time
28
+
29
+ # Get example images
30
+ example_paths = list(pathlib.Path('examples').glob("*/*.jpg"))
31
+ example_list = [[str(filepath)] for filepath in random.sample(example_paths, k=4)]
32
+
33
+ # Set up the Gradio interface
34
+ title = 'Klasifikasi Penyakit Daun Padi'
35
+ description = 'Upload gambar daun padi untuk mengklasifikasikan penyakitnya.'
36
+
37
+ demo = gr.Interface(
38
+ fn=predict,
39
+ inputs=gr.Image(type='pil'),
40
+ outputs=[
41
+ gr.Label(num_top_classes=4, label='Prediksi'),
42
+ gr.Number(label="Waktu prediksi (detik)")
43
+ ],
44
+ description=description,
45
+ title=title,
46
+ allow_flagging='never',
47
+ examples=example_list
48
+ )
49
+
50
+ if __name__ == "__main__":
51
+ demo.launch(debug=True)
examples/Hispa/IMG_20190420_194642.jpg ADDED

Git LFS Details

  • SHA256: bdbfcc425f2ae66f327bbd05309e0adb9c855e25322790ff9db6a02f97e0aa1f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.12 MB
examples/bercak_coklat/Ex brownSpot.jpg ADDED

Git LFS Details

  • SHA256: 98248ebf7110897cb694817635297301a33b2161cfeb2b32ba0d943fa46e8d16
  • Pointer size: 132 Bytes
  • Size of remote file: 2.91 MB
examples/blast_daun/examples_blast_daun_BLAST2_018.jpg ADDED
examples/sehat/examples_sehat_healthy (327).jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ tensorflow==2.15.0
3
+ pillow
4
+ keras==2.15.0