Update app.py
Browse files
app.py
CHANGED
|
@@ -41,17 +41,25 @@ st.write("Upload a brain scan (JPG format), and the model will predict its class
|
|
| 41 |
uploaded_file = st.file_uploader("Choose a JPG image...", type="jpg")
|
| 42 |
|
| 43 |
if uploaded_file is not None:
|
| 44 |
-
|
| 45 |
-
st.
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
uploaded_file = st.file_uploader("Choose a JPG image...", type="jpg")
|
| 42 |
|
| 43 |
if uploaded_file is not None:
|
| 44 |
+
# Display the uploaded image on the left side
|
| 45 |
+
col1, col2 = st.columns([2, 1]) # Create two columns
|
| 46 |
|
| 47 |
+
with col1:
|
| 48 |
+
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
|
| 49 |
|
| 50 |
+
with col2:
|
| 51 |
+
# Button to trigger prediction
|
| 52 |
+
if st.button("Detect"):
|
| 53 |
+
st.write("Detecting...")
|
| 54 |
+
# Load and preprocess the image
|
| 55 |
+
processed_image = load_and_preprocess_image(uploaded_file)
|
| 56 |
+
|
| 57 |
+
# Make prediction
|
| 58 |
+
predicted_class_index = predict_image(processed_image)
|
| 59 |
+
|
| 60 |
+
# Get predicted class label
|
| 61 |
+
predicted_class_label = get_class_label(predicted_class_index)
|
| 62 |
+
|
| 63 |
+
# Center display for the prediction result
|
| 64 |
+
st.markdown(f"<h3 style='color: #4CAF50; text-align: center;'>The predicted class is: <strong>{predicted_class_label}</strong></h3>", unsafe_allow_html=True)
|
| 65 |
+
|