Danush-R commited on
Commit
3b85cb8
1 Parent(s): 8ef30c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -15
app.py CHANGED
@@ -1,13 +1,8 @@
1
  import streamlit as st
2
- import tensorflow as tf
3
  from tensorflow.keras.models import load_model
4
  from tensorflow.keras.preprocessing.image import load_img, img_to_array
5
  import numpy as np
6
  import pickle
7
- import concurrent.futures
8
-
9
- # Ensure TensorFlow is installed
10
- # !pip install tensorflow
11
 
12
  # Load the saved model
13
  model = load_model("best_model.h5")
@@ -32,14 +27,9 @@ def predict_image(image):
32
  predicted_label = class_indices[predicted_class]
33
  return predicted_label
34
 
35
- # Function to handle predictions asynchronously
36
- def async_predict(image):
37
- with concurrent.futures.ThreadPoolExecutor() as executor:
38
- future = executor.submit(predict_image, image)
39
- return future.result()
40
-
41
  # Streamlit App
42
  st.title("Rice Leaf Disease Classification")
 
43
  st.write("Upload an image of a rice leaf and the model will predict its disease category.")
44
 
45
  # File uploader
@@ -52,7 +42,6 @@ if uploaded_file is not None:
52
  st.write("")
53
  st.write("Classifying...")
54
 
55
- # Make a prediction asynchronously
56
- with st.spinner('Wait for it...'):
57
- predicted_label = async_predict(uploaded_file)
58
- st.write(f"Predicted label: {predicted_label}")
 
1
  import streamlit as st
 
2
  from tensorflow.keras.models import load_model
3
  from tensorflow.keras.preprocessing.image import load_img, img_to_array
4
  import numpy as np
5
  import pickle
 
 
 
 
6
 
7
  # Load the saved model
8
  model = load_model("best_model.h5")
 
27
  predicted_label = class_indices[predicted_class]
28
  return predicted_label
29
 
 
 
 
 
 
 
30
  # Streamlit App
31
  st.title("Rice Leaf Disease Classification")
32
+
33
  st.write("Upload an image of a rice leaf and the model will predict its disease category.")
34
 
35
  # File uploader
 
42
  st.write("")
43
  st.write("Classifying...")
44
 
45
+ # Make a prediction
46
+ predicted_label = predict_image(uploaded_file)
47
+ st.write(f"Predicted label: {predicted_label}")