AjaykumarPilla commited on
Commit
ea55c2f
·
verified ·
1 Parent(s): 2dc4406

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
  import pandas as pd
3
  import matplotlib.pyplot as plt
4
  import os
@@ -179,7 +180,7 @@ with st.form("project_form"):
179
  col1, col2 = st.columns(2)
180
 
181
  with col1:
182
- project_name = st.text_input("Project Name", value="Highway Expansion")
183
  phase = st.selectbox("Phase", [""] + ["Planning", "Design", "Construction"], index=0, key="phase_select")
184
 
185
  if phase != st.session_state.phase:
@@ -187,21 +188,20 @@ with st.form("project_form"):
187
  st.session_state.task = ""
188
  task_options_list = [""] + task_options.get(phase, []) if phase else [""]
189
  task = st.selectbox("Task", task_options_list, index=0, key="task_select")
190
- current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=70.0)
191
- task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=10)
192
- task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=12)
193
 
194
  with col2:
195
- workforce_gap = st.number_input("Workforce Gap (%)", min_value=0.0, max_value=100.0, step=1.0, value=20.0)
196
- workforce_skill_level = st.selectbox("Workforce Skill Level", ["Low", "Medium", "High"], index=1)
197
- workforce_shift_hours = st.number_input("Workforce Shift Hours", min_value=0, step=1, value=6)
198
  st.write(f"**Selected Shift Hours**: {workforce_shift_hours}")
199
- weather_impact_score = st.number_input("Weather Impact Score (0-100)", min_value=0, max_value=100, step=1, value=60)
200
  weather_condition = get_weather_condition(weather_impact_score)
201
  st.write(f"**Weather Condition**: {weather_condition}")
202
- weather_forecast_date = st.date_input("Weather Forecast Date", min_value=datetime(2025, 1, 1), value=datetime(2025, 5, 23))
203
 
204
- st.info("Note: AI insights are generated using DistilBART, which may take ~5-10 seconds on CPU.")
205
  submit_button = st.form_submit_button("Predict Delay")
206
 
207
  # Process form submission
@@ -219,7 +219,7 @@ if submit_button:
219
  "workforce_shift_hours": workforce_shift_hours,
220
  "weather_impact_score": weather_impact_score,
221
  "weather_condition": weather_condition,
222
- "weather_forecast_date": weather_forecast_date.strftime("%Y-%m-%d")
223
  }
224
 
225
  error = validate_inputs(input_data)
@@ -257,7 +257,7 @@ if submit_button:
257
  new Chart(ctx, {json.dumps(chart_config)});
258
  </script>
259
  """
260
- st.markdown(chart_html, unsafe_allow_html=True)
261
  logger.info("Chart.js heatmap rendered")
262
 
263
  # Generate matplotlib figure for PDF
 
1
  import streamlit as st
2
+ import streamlit.components.v1 as components
3
  import pandas as pd
4
  import matplotlib.pyplot as plt
5
  import os
 
180
  col1, col2 = st.columns(2)
181
 
182
  with col1:
183
+ project_name = st.text_input("Project Name")
184
  phase = st.selectbox("Phase", [""] + ["Planning", "Design", "Construction"], index=0, key="phase_select")
185
 
186
  if phase != st.session_state.phase:
 
188
  st.session_state.task = ""
189
  task_options_list = [""] + task_options.get(phase, []) if phase else [""]
190
  task = st.selectbox("Task", task_options_list, index=0, key="task_select")
191
+ current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
192
+ task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0)
193
+ task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0)
194
 
195
  with col2:
196
+ workforce_gap = st.number_input("Workforce Gap (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
197
+ workforce_skill_level = st.selectbox("Workforce Skill Level", ["", "Low", "Medium", "High"], index=0)
198
+ workforce_shift_hours = st.number_input("Workforce Shift Hours", min_value=0, step=1, value=0)
199
  st.write(f"**Selected Shift Hours**: {workforce_shift_hours}")
200
+ weather_impact_score = st.number_input("Weather Impact Score (0-100)", min_value=0, max_value=100, step=1, value=0)
201
  weather_condition = get_weather_condition(weather_impact_score)
202
  st.write(f"**Weather Condition**: {weather_condition}")
203
+ weather_forecast_date = st.date_input("Weather Forecast Date", min_value=datetime(2025, 1, 1), value=None)
204
 
 
205
  submit_button = st.form_submit_button("Predict Delay")
206
 
207
  # Process form submission
 
219
  "workforce_shift_hours": workforce_shift_hours,
220
  "weather_impact_score": weather_impact_score,
221
  "weather_condition": weather_condition,
222
+ "weather_forecast_date": weather_forecast_date.strftime("%Y-%m-%d") if weather_forecast_date else ""
223
  }
224
 
225
  error = validate_inputs(input_data)
 
257
  new Chart(ctx, {json.dumps(chart_config)});
258
  </script>
259
  """
260
+ components.html(chart_html, height=250)
261
  logger.info("Chart.js heatmap rendered")
262
 
263
  # Generate matplotlib figure for PDF