ifiecas commited on
Commit
b771194
·
verified ·
1 Parent(s): 4dd3861

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -135,10 +135,21 @@ def load_model():
135
 
136
  model = load_model()
137
 
 
 
 
 
138
  # Create tabs for better organization
139
  tab1, tab2 = st.tabs(["Loan Application", "About the System"])
140
 
141
  with tab1:
 
 
 
 
 
 
 
142
  # Personal Information Section
143
  st.markdown('<div class="section-card"><h3>Personal Information</h3>', unsafe_allow_html=True)
144
 
@@ -278,10 +289,15 @@ with tab1:
278
 
279
  st.markdown('</div>', unsafe_allow_html=True)
280
 
281
- # Prediction button with enhanced styling
282
- st.markdown('<div style="padding: 1.5rem 0;">', unsafe_allow_html=True)
283
- predict_button = st.button("Check Loan Approval Status")
284
- st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
285
 
286
  def preprocess_input():
287
  # Convert categorical inputs to numerical format based on encoding reference
@@ -311,6 +327,11 @@ with tab1:
311
  credit_amount_interaction, income_term_ratio
312
  ]])
313
 
 
 
 
 
 
314
  # Display prediction
315
  if predict_button:
316
  with st.spinner("Processing your application..."):
 
135
 
136
  model = load_model()
137
 
138
+ # Initialize session state for restart functionality
139
+ if 'restart_clicked' not in st.session_state:
140
+ st.session_state.restart_clicked = False
141
+
142
  # Create tabs for better organization
143
  tab1, tab2 = st.tabs(["Loan Application", "About the System"])
144
 
145
  with tab1:
146
+ # Reset all form values if restart was clicked
147
+ if st.session_state.restart_clicked:
148
+ st.session_state.restart_clicked = False # Reset flag
149
+
150
+ # Add any other reset logic here if needed
151
+ # Note: Streamlit will reset most inputs automatically on rerun
152
+
153
  # Personal Information Section
154
  st.markdown('<div class="section-card"><h3>Personal Information</h3>', unsafe_allow_html=True)
155
 
 
289
 
290
  st.markdown('</div>', unsafe_allow_html=True)
291
 
292
+ # Prediction and restart buttons
293
+ col1, col2 = st.columns([3, 1])
294
+
295
+ with col1:
296
+ predict_button = st.button("Check Loan Approval Status", use_container_width=True)
297
+
298
+ with col2:
299
+ restart_button = st.button("🔄 Restart", use_container_width=True,
300
+ help="Reset all form fields and start over")
301
 
302
  def preprocess_input():
303
  # Convert categorical inputs to numerical format based on encoding reference
 
327
  credit_amount_interaction, income_term_ratio
328
  ]])
329
 
330
+ # Handle restart button click
331
+ if restart_button:
332
+ st.session_state.restart_clicked = True
333
+ st.experimental_rerun()
334
+
335
  # Display prediction
336
  if predict_button:
337
  with st.spinner("Processing your application..."):