Heizsenberg commited on
Commit
1724c49
·
1 Parent(s): 4d8779f

push keras file

Browse files
src/__pycache__/prediction.cpython-310.pyc CHANGED
Binary files a/src/__pycache__/prediction.cpython-310.pyc and b/src/__pycache__/prediction.cpython-310.pyc differ
 
src/prediction.py CHANGED
@@ -2,6 +2,8 @@ import numpy as np
2
  import streamlit as st
3
  import tensorflow as tf
4
  from PIL import Image
 
 
5
 
6
  class_names = [
7
  'Tomato_Bacterial_spot',
@@ -17,8 +19,14 @@ class_names = [
17
  ]
18
 
19
  @st.cache_resource
20
- def load_my_model():
21
- return tf.keras.models.load_model("leaf_detection_model.keras")
 
 
 
 
 
 
22
 
23
 
24
  def predict_image(model, img):
@@ -38,7 +46,7 @@ def predict_image(model, img):
38
  return img, predicted_label, confidence
39
 
40
  def run():
41
- classifier_model = load_my_model()
42
 
43
  st.write("upload a tomato leaf image to be predicted")
44
 
 
2
  import streamlit as st
3
  import tensorflow as tf
4
  from PIL import Image
5
+ from huggingface_hub import hf_hub_download
6
+
7
 
8
  class_names = [
9
  'Tomato_Bacterial_spot',
 
19
  ]
20
 
21
  @st.cache_resource
22
+ def load_model_from_hub():
23
+ model_path = hf_hub_download(
24
+ repo_id="Heizsenberg/leaf-classification-tomato",
25
+ filename="leaf_detection_model.keras"
26
+ )
27
+ model = tf.keras.models.load_model(model_path)
28
+ return model
29
+
30
 
31
 
32
  def predict_image(model, img):
 
46
  return img, predicted_label, confidence
47
 
48
  def run():
49
+ classifier_model = load_model_from_hub()
50
 
51
  st.write("upload a tomato leaf image to be predicted")
52