Yadvendra commited on
Commit
a66cca5
·
verified ·
1 Parent(s): ebf027a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
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
- st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
45
- st.write("Detecting...")
46
 
47
- # Load and preprocess the image
48
- processed_image = load_and_preprocess_image(uploaded_file)
49
 
50
- # Make prediction
51
- predicted_class_index = predict_image(processed_image)
52
-
53
- # Get predicted class label
54
- predicted_class_label = get_class_label(predicted_class_index)
55
-
56
- # Display the result
57
- st.markdown(f"<h3 style='color: #4CAF50;'>The predicted class is: <strong>{predicted_class_label}</strong></h3>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
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
+