SonFox2920 commited on
Commit
1f2f1b7
·
verified ·
1 Parent(s): 4c5b0d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -126,29 +126,27 @@ def main():
126
  # Display uploaded image
127
  image = Image.open(uploaded_file)
128
  st.image(image, caption="Uploaded Image", use_column_width=True)
129
-
130
- # Add predict button
131
- if st.button("Predict"):
132
- with st.spinner('Analyzing image...'):
133
- try:
134
- # Load model
135
- model = load_model()
136
-
137
- # Preprocess image
138
- processed_image = preprocess_image(image)
139
-
140
- # Make prediction
141
- prediction = model.predict(np.expand_dims(processed_image, axis=0))
142
- class_names = ['10', '6.5', '7', '7.5', '8', '8.5', '9', '9.2', '9.5', '9.7']
143
-
144
- # Get top 5 predictions
145
- top_predictions = get_top_predictions(prediction, class_names)
146
-
147
- # Store in session state
148
- st.session_state.predictions = top_predictions
149
-
150
- except Exception as e:
151
- st.error(f"Error during prediction: {str(e)}")
152
 
153
  with col2:
154
  st.subheader("Prediction Results")
 
126
  # Display uploaded image
127
  image = Image.open(uploaded_file)
128
  st.image(image, caption="Uploaded Image", use_column_width=True)
129
+
130
+ with st.spinner('Analyzing image...'):
131
+ try:
132
+ # Load model
133
+ model = load_model()
134
+
135
+ # Preprocess image
136
+ processed_image = preprocess_image(image)
137
+
138
+ # Make prediction
139
+ prediction = model.predict(np.expand_dims(processed_image, axis=0))
140
+ class_names = ['10', '6.5', '7', '7.5', '8', '8.5', '9', '9.2', '9.5', '9.7']
141
+
142
+ # Get top 5 predictions
143
+ top_predictions = get_top_predictions(prediction, class_names)
144
+
145
+ # Store in session state
146
+ st.session_state.predictions = top_predictions
147
+
148
+ except Exception as e:
149
+ st.error(f"Error during prediction: {str(e)}")
 
 
150
 
151
  with col2:
152
  st.subheader("Prediction Results")