Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,37 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
st.title("Plant Disease Detection")
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
if
|
15 |
-
|
16 |
|
17 |
# Display the prediction
|
18 |
-
st.
|
19 |
-
st.text(prediction[0]["label"])
|
20 |
|
21 |
-
|
22 |
-
|
|
|
1 |
import streamlit as st
|
2 |
+
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
pipe = pipeline("image-classification", model="ombhojane/healthyPlantsModel")
|
6 |
+
|
7 |
+
def predict_disease(image):
|
8 |
+
"""Predicts the disease of a plant from an image.
|
9 |
+
|
10 |
+
Args:
|
11 |
+
image: A NumPy array representing the image.
|
12 |
+
|
13 |
+
Returns:
|
14 |
+
A string representing the predicted disease.
|
15 |
+
"""
|
16 |
+
|
17 |
+
prediction = pipe(image)
|
18 |
+
label = prediction[0]["label"]
|
19 |
+
return label
|
20 |
+
|
21 |
+
def main():
|
22 |
+
"""Creates the Streamlit app."""
|
23 |
|
24 |
+
st.title("Plant Disease Detection App")
|
|
|
25 |
|
26 |
+
# Upload an image
|
27 |
+
image = st.file_uploader("Upload an image of a plant")
|
28 |
|
29 |
+
# Predict the disease
|
30 |
+
if image is not None:
|
31 |
+
disease = predict_disease(image)
|
32 |
|
33 |
# Display the prediction
|
34 |
+
st.markdown(f"Predicted disease: {disease}")
|
|
|
35 |
|
36 |
+
if __name__ == "__main__":
|
37 |
+
main()
|