Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,6 +25,13 @@ warnings.filterwarnings("ignore")
|
|
| 25 |
# Setting the title and adding text
|
| 26 |
st.title('Parking Occupancy Detection System')
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# Creating tabs for the different features of the application
|
| 29 |
tab1,tab2,tab3,tab4, tab5 = st.tabs(['Parking lot status', 'Magnetic Field Explorer', 'About', 'Dataset and visualisations', 'Model performance'])
|
| 30 |
|
|
@@ -73,26 +80,9 @@ with tab1:
|
|
| 73 |
# Retrieving building data
|
| 74 |
building_new = retrieve_building()
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
def fill_nan_with_zero(value):
|
| 79 |
-
if pd.isna(value):
|
| 80 |
-
return 0
|
| 81 |
-
else:
|
| 82 |
-
return value
|
| 83 |
-
|
| 84 |
-
def add_small_value_if_zero(value):
|
| 85 |
-
if value == 0:
|
| 86 |
-
return value + 0.0001
|
| 87 |
-
else:
|
| 88 |
-
return value
|
| 89 |
-
|
| 90 |
building_mag_prediction_data['et0_fao_evapotranspiration'] = building_mag_prediction_data['et0_fao_evapotranspiration'].apply(fill_nan_with_zero)
|
| 91 |
-
#building_mag_prediction_data['et0_fao_evapotranspiration'] = building_mag_prediction_data['et0_fao_evapotranspiration'].apply(add_small_value_if_zero)
|
| 92 |
-
|
| 93 |
-
st.dataframe(building_mag_prediction_data)
|
| 94 |
-
|
| 95 |
-
# Making the predictions and getting the latest data
|
| 96 |
building_mag_most_recent_prediction = building_mag_prediction_data[['x', 'y', 'z', 'temperature', 'et0_fao_evapotranspiration']]
|
| 97 |
building_mag_most_recent_prediction = building_mag_hist_model.predict(building_mag_most_recent_prediction)
|
| 98 |
building_mag_prediction_data['Status'] = building_mag_most_recent_prediction
|
|
@@ -101,6 +91,17 @@ with tab1:
|
|
| 101 |
building_mag_prediction_data = building_mag_prediction_data.set_index(['Time'])
|
| 102 |
st.dataframe(building_mag_prediction_data[['Status']].tail(3))
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
with col2:
|
| 106 |
st.subheader("Parking place near bikelane:")
|
|
|
|
| 25 |
# Setting the title and adding text
|
| 26 |
st.title('Parking Occupancy Detection System')
|
| 27 |
|
| 28 |
+
# Defining functions
|
| 29 |
+
def fill_nan_with_zero(value):
|
| 30 |
+
if pd.isna(value):
|
| 31 |
+
return 0
|
| 32 |
+
else:
|
| 33 |
+
return value
|
| 34 |
+
|
| 35 |
# Creating tabs for the different features of the application
|
| 36 |
tab1,tab2,tab3,tab4, tab5 = st.tabs(['Parking lot status', 'Magnetic Field Explorer', 'About', 'Dataset and visualisations', 'Model performance'])
|
| 37 |
|
|
|
|
| 80 |
# Retrieving building data
|
| 81 |
building_new = retrieve_building()
|
| 82 |
|
| 83 |
+
# Making the predictions and getting the latest data for magnetic field data
|
| 84 |
+
building_mag_prediction_data = building_new[['time', 'x', 'y', 'z', 'temperature', 'et0_fao_evapotranspiration']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
building_mag_prediction_data['et0_fao_evapotranspiration'] = building_mag_prediction_data['et0_fao_evapotranspiration'].apply(fill_nan_with_zero)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
building_mag_most_recent_prediction = building_mag_prediction_data[['x', 'y', 'z', 'temperature', 'et0_fao_evapotranspiration']]
|
| 87 |
building_mag_most_recent_prediction = building_mag_hist_model.predict(building_mag_most_recent_prediction)
|
| 88 |
building_mag_prediction_data['Status'] = building_mag_most_recent_prediction
|
|
|
|
| 91 |
building_mag_prediction_data = building_mag_prediction_data.set_index(['Time'])
|
| 92 |
st.dataframe(building_mag_prediction_data[['Status']].tail(3))
|
| 93 |
|
| 94 |
+
# Making the predictions and getting the latest data for radar data
|
| 95 |
+
building_rad_prediction_data = building_new[['time', 'radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7', 'temperature', 'et0_fao_evapotranspiration']]
|
| 96 |
+
building_rad_prediction_data['et0_fao_evapotranspiration'] = building_rad_prediction_data['et0_fao_evapotranspiration'].apply(fill_nan_with_zero)
|
| 97 |
+
building_rad_most_recent_prediction = building_rad_prediction_data[['radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7', 'temperature', 'et0_fao_evapotranspiration']]
|
| 98 |
+
building_rad_most_recent_prediction = building_rad_hist_model.predict(building_rad_most_recent_prediction)
|
| 99 |
+
building_rad_prediction_data['Status'] = building_rad_most_recent_prediction
|
| 100 |
+
building_rad_prediction_data['Status'].replace(['detection', 'no_detection'], ['Vehicle detected', 'No vehicle detected'], inplace=True)
|
| 101 |
+
building_rad_prediction_data = building_rad_prediction_data.rename(columns={'time': 'Time'})
|
| 102 |
+
building_rad_prediction_data = building_rad_prediction_data.set_index(['Time'])
|
| 103 |
+
st.dataframe(building_rad_prediction_data[['Status']].tail(3))
|
| 104 |
+
|
| 105 |
|
| 106 |
with col2:
|
| 107 |
st.subheader("Parking place near bikelane:")
|