Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -243,91 +243,7 @@ def load_data():
|
|
| 243 |
return df
|
| 244 |
|
| 245 |
df = load_data()
|
| 246 |
-
# @st.cache_data
|
| 247 |
-
# def load_data():
|
| 248 |
-
# try:
|
| 249 |
-
# # Load main data
|
| 250 |
-
# df = pd.read_excel("df_final.xlsx", sheet_name="Sheet1")
|
| 251 |
-
# # Load health index data
|
| 252 |
-
# hi_data = pd.read_excel("hi_final.xlsx")
|
| 253 |
-
# except FileNotFoundError as e:
|
| 254 |
-
# st.error(f"❌ File not found: `{e.filename}`")
|
| 255 |
-
# st.stop()
|
| 256 |
-
# except Exception as e:
|
| 257 |
-
# st.error(f"❌ Error loading data: {e}")
|
| 258 |
-
# st.stop()
|
| 259 |
-
|
| 260 |
-
# # === Proses df_final.xlsx ===
|
| 261 |
-
# # Fix encoding
|
| 262 |
-
# df.columns = df.columns.str.replace("Â", "")
|
| 263 |
-
# for col in df.select_dtypes(include='object').columns:
|
| 264 |
-
# df[col] = df[col].astype(str).str.replace("Â", "")
|
| 265 |
-
|
| 266 |
-
# # Parse datetime
|
| 267 |
-
# df['Time'] = pd.to_datetime(df['Time'], errors='coerce')
|
| 268 |
-
# df = df.dropna(subset=['Time']).copy()
|
| 269 |
-
# df['hour'] = df['Time'].dt.hour
|
| 270 |
-
|
| 271 |
-
# # Alarm flag
|
| 272 |
-
# df['is_alarm'] = (~df['Alarm Status'].fillna('').str.contains('No Alarm', case=False)).astype(int)
|
| 273 |
-
|
| 274 |
-
# # Dynamic risk score
|
| 275 |
-
# p = df['Pressure (psi)']
|
| 276 |
-
# p_red_high = df['Red High Press (psi)']
|
| 277 |
-
# p_amber_high = df['Amber High Press (psi)']
|
| 278 |
-
# t = df['Temperature (°C)']
|
| 279 |
-
# t_red = df['Absolute Red Temp (°C)']
|
| 280 |
-
# t_amber = df['Absolute Amber Temp (°C)']
|
| 281 |
-
|
| 282 |
-
# # Avoid division by zero
|
| 283 |
-
# p_denom = (p_red_high - p_amber_high).replace(0, np.nan)
|
| 284 |
-
# p_norm = np.clip((p - p_amber_high) / p_denom, 0, 1).fillna(0)
|
| 285 |
-
# t_denom = (t_red - t_amber).replace(0, np.nan)
|
| 286 |
-
# t_norm = np.clip((t - t_amber) / t_denom, 0, 1).fillna(0)
|
| 287 |
-
# df['risk_score'] = 0.6 * p_norm + 0.4 * t_norm
|
| 288 |
-
|
| 289 |
-
# def get_risk_label(score):
|
| 290 |
-
# if score >= 0.8: return 'Very High Risk'
|
| 291 |
-
# elif score >= 0.6: return 'High Risk'
|
| 292 |
-
# elif score >= 0.3: return 'Moderate Risk'
|
| 293 |
-
# else: return 'Slight Risk'
|
| 294 |
-
# df['Risk Level'] = df['risk_score'].apply(get_risk_label)
|
| 295 |
-
|
| 296 |
-
# # Position Group
|
| 297 |
-
# df['Position Group'] = df['Position'].map({1: 'Front', 2: 'Front', 3: 'Rear', 4: 'Rear'}).fillna('Other')
|
| 298 |
-
|
| 299 |
-
# return df, hi_data # Kembalikan 2 data
|
| 300 |
-
# # Load both datasets
|
| 301 |
-
# df, hi_data = load_data()
|
| 302 |
-
# # Optional: Info ringkas di sidebar (opsional)
|
| 303 |
-
# with st.sidebar:
|
| 304 |
-
# st.markdown("### 📊 Dataset Overview")
|
| 305 |
-
# st.metric("Total Records", f"{len(df):,}")
|
| 306 |
-
# st.metric("Date Range", f"{df['Time'].min().date()} → {df['Time'].max().date()}")
|
| 307 |
-
# st.metric("Alarms (Red/Amber)", f"{df['is_alarm'].sum():,} ({df['is_alarm'].mean():.1%})")
|
| 308 |
-
|
| 309 |
-
# ================= HEADER =================
|
| 310 |
-
st.markdown("""
|
| 311 |
-
<div style="text-align:center; font-family:Arial, sans-serif; margin-bottom:16px;">
|
| 312 |
-
<h1 style="color:#154D9C; font-weight:bold; margin:0;">
|
| 313 |
-
Tyre Pressure Monitoring System (TPMS) Analytics for Mining Equipments
|
| 314 |
-
</h1>
|
| 315 |
-
|
| 316 |
-
<p style="font-size:12px; color:#7d7d7d; margin:4px 0 2px 0;">
|
| 317 |
-
Daily trend insights derived from 13–16 December 2023 data
|
| 318 |
-
</p>
|
| 319 |
-
|
| 320 |
-
<p style="font-size:11px; color:#5DA698; margin:6px 0 2px 0; font-weight:600;">
|
| 321 |
-
Special Design from <span style="color:#154D9C;">Bukit Technology Digital</span>
|
| 322 |
-
</p>
|
| 323 |
|
| 324 |
-
<p style="font-size:10px; color:#7d7d7d; margin:2px 0 10px 0;">
|
| 325 |
-
© 2025 Bukit Technology Digital. All rights reserved.
|
| 326 |
-
</p>
|
| 327 |
-
</div>
|
| 328 |
-
""", unsafe_allow_html=True)
|
| 329 |
-
|
| 330 |
-
# ================= LOGO SECTION (FROM HUGGING FACE URL) =================
|
| 331 |
col1, col2, col3 = st.columns([1, 4, 1])
|
| 332 |
|
| 333 |
with col1:
|
|
@@ -337,72 +253,28 @@ with col1:
|
|
| 337 |
)
|
| 338 |
|
| 339 |
with col2:
|
| 340 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
|
| 342 |
with col3:
|
| 343 |
st.image(
|
| 344 |
-
"https://huggingface.co/spaces/bukittechnology/tyre/resolve/main/
|
| 345 |
width=120
|
| 346 |
)
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
-
# ================= OBJECTIVES (1–6) =================
|
| 351 |
-
|
| 352 |
-
# # ================= HEADER =================
|
| 353 |
-
# st.markdown("""
|
| 354 |
-
# <div class="main-header" style="text-align:center;">
|
| 355 |
-
# <h1>Michelin Mining Tyre Analytics</h1>
|
| 356 |
-
# <p style="font-size:14px; color:#b0b0b0; margin-top:-10px;">
|
| 357 |
-
# Analysis is based on daily aggregated data
|
| 358 |
-
# </p>
|
| 359 |
-
# </div>
|
| 360 |
-
# """, unsafe_allow_html=True)
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
# ================= LOGO (Perbaikan: Base64 Embed - Selalu Muncul) =================
|
| 365 |
-
# ================= LOGO (Pakai File Lokal - Selalu Muncul di Pojok Kanan Atas) =================
|
| 366 |
-
# import os
|
| 367 |
-
# import streamlit as st
|
| 368 |
-
|
| 369 |
-
# # ================= PATH AMAN (WAJIB) =================
|
| 370 |
-
# BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 371 |
-
|
| 372 |
-
# LOGO_MICHELIN = os.path.join(BASE_DIR, "logo.png")
|
| 373 |
-
# LOGO_BTECH = os.path.join(BASE_DIR, "btech.png")
|
| 374 |
-
|
| 375 |
-
# # ================= HEADER =================
|
| 376 |
-
# with st.container():
|
| 377 |
-
# col1, col2, col3 = st.columns([1.5, 6, 1.5])
|
| 378 |
-
|
| 379 |
-
# # LEFT — Michelin Logo
|
| 380 |
-
# with col1:
|
| 381 |
-
# if os.path.exists(LOGO_MICHELIN):
|
| 382 |
-
# st.image(LOGO_MICHELIN, width=140)
|
| 383 |
-
# else:
|
| 384 |
-
# st.markdown("**Michelin**")
|
| 385 |
-
|
| 386 |
-
# # CENTER — Title
|
| 387 |
-
# with col2:
|
| 388 |
-
# st.markdown("""
|
| 389 |
-
# <div style="text-align:center;">
|
| 390 |
-
# <h1 style="margin:0; color:#154D9C; font-weight:800;">
|
| 391 |
-
# Tyre Pressure Monitoring System (TPMS) Analytics for Mining Equipments
|
| 392 |
-
# </h1>
|
| 393 |
-
# <p style="font-size:12px; color:#7d7d7d; margin-top:6px;">
|
| 394 |
-
# Daily trend insights derived from 13–16 December 2023 data
|
| 395 |
-
# </p>
|
| 396 |
-
# </div>
|
| 397 |
-
# """, unsafe_allow_html=True)
|
| 398 |
-
|
| 399 |
-
# # RIGHT — BTech Logo
|
| 400 |
-
# with col3:
|
| 401 |
-
# if os.path.exists(LOGO_BTECH):
|
| 402 |
-
# st.image(LOGO_BTECH, width=140)
|
| 403 |
-
# else:
|
| 404 |
-
# st.markdown("**BTech**")
|
| 405 |
-
|
| 406 |
# ================= SIDEBAR FILTERS =================
|
| 407 |
with st.sidebar:
|
| 408 |
st.markdown("### Filter")
|
|
@@ -1662,7 +1534,7 @@ st.markdown("""
|
|
| 1662 |
font-family: Arial, sans-serif;
|
| 1663 |
border-top: 1px solid #f0f0f0;
|
| 1664 |
">
|
| 1665 |
-
<div style="font-weight: bold; color: #
|
| 1666 |
Michelin Mining Tyre Analytics
|
| 1667 |
</div>
|
| 1668 |
<div style="font-size: 10px; color: #7d7d7d;">
|
|
|
|
| 243 |
return df
|
| 244 |
|
| 245 |
df = load_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
col1, col2, col3 = st.columns([1, 4, 1])
|
| 248 |
|
| 249 |
with col1:
|
|
|
|
| 253 |
)
|
| 254 |
|
| 255 |
with col2:
|
| 256 |
+
st.markdown("""
|
| 257 |
+
<div style="text-align:center; font-family:Arial, sans-serif; margin-bottom:16px;">
|
| 258 |
+
<h1 style="color:#154D9C; font-weight:bold; margin:0;">
|
| 259 |
+
Tyre Pressure Monitoring System (TPMS) Analytics for Mining Equipments
|
| 260 |
+
</h1>
|
| 261 |
+
<p style="font-size:12px; color:#7d7d7d; margin:4px 0 2px 0;">
|
| 262 |
+
Daily trend insights derived from 13–16 December 2023 data
|
| 263 |
+
</p>
|
| 264 |
+
<p style="font-size:10px; color:#7d7d7d; margin:2px 0 0 0;">
|
| 265 |
+
© 2025 Bukit Technology Digital. All rights reserved.
|
| 266 |
+
</p>
|
| 267 |
+
</div>
|
| 268 |
+
""", unsafe_allow_html=True)
|
| 269 |
|
| 270 |
with col3:
|
| 271 |
st.image(
|
| 272 |
+
"https://huggingface.co/spaces/bukittechnology/tyre/resolve/main/img-logo-BTech.webp",
|
| 273 |
width=120
|
| 274 |
)
|
| 275 |
|
| 276 |
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
# ================= SIDEBAR FILTERS =================
|
| 279 |
with st.sidebar:
|
| 280 |
st.markdown("### Filter")
|
|
|
|
| 1534 |
font-family: Arial, sans-serif;
|
| 1535 |
border-top: 1px solid #f0f0f0;
|
| 1536 |
">
|
| 1537 |
+
<div style="font-weight: bold; color: #7d7d7d; margin-bottom: 4px;">
|
| 1538 |
Michelin Mining Tyre Analytics
|
| 1539 |
</div>
|
| 1540 |
<div style="font-size: 10px; color: #7d7d7d;">
|