Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
4 |
from keras.models import load_model
|
@@ -47,26 +47,7 @@ def predict_ripeness(image):
|
|
47 |
predicted_label = class_names_ripeness[predicted_class]
|
48 |
return predicted_label
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
st.write("Choose an option to analyze bananas")
|
53 |
|
54 |
-
|
55 |
-
analysis_option = st.radio("Choose an option", ["Banana Disease Detection", "Banana Ripeness Detection"])
|
56 |
-
|
57 |
-
# File uploader
|
58 |
-
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
59 |
-
|
60 |
-
if uploaded_file is not None:
|
61 |
-
# Display the uploaded image
|
62 |
-
st.image(uploaded_file, caption='Uploaded Image', use_column_width=True)
|
63 |
-
if st.button("Analyze"):
|
64 |
-
if analysis_option == "Banana Disease Detection":
|
65 |
-
predicted_label = predict_disease(uploaded_file)
|
66 |
-
st.success(f"Predicted disease: {predicted_label}")
|
67 |
-
elif analysis_option == "Banana Ripeness Detection":
|
68 |
-
predicted_label = predict_ripeness(uploaded_file)
|
69 |
-
st.success(f"Predicted ripeness: {predicted_label}")
|
70 |
-
|
71 |
-
if __name__ == '__main__':
|
72 |
-
main()
|
|
|
1 |
+
import gradio as gr
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
4 |
from keras.models import load_model
|
|
|
47 |
predicted_label = class_names_ripeness[predicted_class]
|
48 |
return predicted_label
|
49 |
|
50 |
+
inputs = gr.inputs.File(label="Upload an image...")
|
51 |
+
outputs = gr.outputs.Textbox(label="Prediction")
|
|
|
52 |
|
53 |
+
gr.Interface(fn=predict_disease, inputs=inputs, outputs=outputs, title="Banana Disease Detection").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|