Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
-
import plotly.express as px
|
| 5 |
-
import plotly.graph_objects as go
|
| 6 |
-
from sklearn.linear_model import LinearRegression
|
| 7 |
|
| 8 |
# ================= LOAD DATA =================
|
| 9 |
try:
|
|
@@ -23,7 +20,6 @@ except FileNotFoundError:
|
|
| 23 |
print("⚠️ File df_final.xlsx not found. Running with dummy data.")
|
| 24 |
|
| 25 |
# ================= SIMULASI PRESSURE BERDASARKAN GRADIEN =================
|
| 26 |
-
# Definisikan rumus gradien berdasarkan tabel Anda
|
| 27 |
pressure_formulas = {
|
| 28 |
(10, 'High', 'Min'): (76.658370666499, 0.424510125965938),
|
| 29 |
(10, 'High', 'Max'): (81.0954797166173, 0.445533183),
|
|
@@ -41,50 +37,89 @@ def calculate_pressure(tyre_type, temp, condition, min_max):
|
|
| 41 |
return intercept + gradient * temp
|
| 42 |
return None
|
| 43 |
|
| 44 |
-
# =================
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# ================= LOAD DATA =================
|
| 6 |
try:
|
|
|
|
| 20 |
print("⚠️ File df_final.xlsx not found. Running with dummy data.")
|
| 21 |
|
| 22 |
# ================= SIMULASI PRESSURE BERDASARKAN GRADIEN =================
|
|
|
|
| 23 |
pressure_formulas = {
|
| 24 |
(10, 'High', 'Min'): (76.658370666499, 0.424510125965938),
|
| 25 |
(10, 'High', 'Max'): (81.0954797166173, 0.445533183),
|
|
|
|
| 37 |
return intercept + gradient * temp
|
| 38 |
return None
|
| 39 |
|
| 40 |
+
# ================= CUSTOM CSS (Dark Theme Premium) =================
|
| 41 |
+
custom_css = """
|
| 42 |
+
<style>
|
| 43 |
+
body {
|
| 44 |
+
background: #000000;
|
| 45 |
+
color: #ffffff;
|
| 46 |
+
font-family: 'Segoe UI', system-ui, sans-serif;
|
| 47 |
+
}
|
| 48 |
+
.gradio-container {
|
| 49 |
+
background: #000000 !important;
|
| 50 |
+
padding: 20px;
|
| 51 |
+
}
|
| 52 |
+
h1, h2, h3, h4, h5, h6 {
|
| 53 |
+
color: #ffffff !important;
|
| 54 |
+
}
|
| 55 |
+
label {
|
| 56 |
+
color: #cccccc !important;
|
| 57 |
+
}
|
| 58 |
+
input, select, button {
|
| 59 |
+
background: #1a1a1a !important;
|
| 60 |
+
color: #ffffff !important;
|
| 61 |
+
border: 1px solid #333333 !important;
|
| 62 |
+
border-radius: 8px !important;
|
| 63 |
+
}
|
| 64 |
+
button {
|
| 65 |
+
background: #003A8F !important;
|
| 66 |
+
color: white !important;
|
| 67 |
+
font-weight: bold;
|
| 68 |
+
padding: 10px 20px;
|
| 69 |
+
transition: all 0.2s ease;
|
| 70 |
+
}
|
| 71 |
+
button:hover {
|
| 72 |
+
background: #002d6b !important;
|
| 73 |
+
transform: translateY(-1px);
|
| 74 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
| 75 |
+
}
|
| 76 |
+
.gradio-box {
|
| 77 |
+
background: #121212 !important;
|
| 78 |
+
border: 1px solid #333333 !important;
|
| 79 |
+
border-radius: 12px !important;
|
| 80 |
+
padding: 20px !important;
|
| 81 |
+
margin: 10px 0 !important;
|
| 82 |
+
}
|
| 83 |
+
.gradio-markdown {
|
| 84 |
+
color: #ffffff !important;
|
| 85 |
+
}
|
| 86 |
+
.gradio-slider .track {
|
| 87 |
+
background: #FFD100 !important;
|
| 88 |
+
}
|
| 89 |
+
.gradio-slider .thumb {
|
| 90 |
+
background: #FFD100 !important;
|
| 91 |
+
border: 2px solid #000000 !important;
|
| 92 |
+
}
|
| 93 |
+
.output-area {
|
| 94 |
+
background: #1e1e1e !important;
|
| 95 |
+
border: 1px solid #333333 !important;
|
| 96 |
+
border-radius: 12px !important;
|
| 97 |
+
padding: 20px !important;
|
| 98 |
+
margin-top: 20px !important;
|
| 99 |
+
font-family: 'Courier New', monospace;
|
| 100 |
+
font-size: 14px;
|
| 101 |
+
line-height: 1.6;
|
| 102 |
+
}
|
| 103 |
+
.output-area p {
|
| 104 |
+
margin: 5px 0;
|
| 105 |
+
}
|
| 106 |
+
.output-area .recommendation {
|
| 107 |
+
color: #00FF00;
|
| 108 |
+
font-weight: bold;
|
| 109 |
+
}
|
| 110 |
+
.output-area .warning {
|
| 111 |
+
color: #FFA500;
|
| 112 |
+
font-weight: bold;
|
| 113 |
+
}
|
| 114 |
+
.output-area .danger {
|
| 115 |
+
color: #FF0000;
|
| 116 |
+
font-weight: bold;
|
| 117 |
+
}
|
| 118 |
+
</style>
|
| 119 |
+
"""
|
| 120 |
|
| 121 |
+
# ================= GRADIO INTERFACE =================
|
| 122 |
+
with gr.Blocks(title="Michelin Mining Tyre Analytics — Objective 6", css=custom_css) as demo:
|
| 123 |
+
gr.HTML("""
|
| 124 |
+
<div style="text-align:center; padding:20px;">
|
| 125 |
+
<img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4KICA8cGF0aCBmaWxsPSIjMDAzQTg4IiBkPSJNMjAgMTVjLTEuMSAwLTIuMi0uOS0yLjItMi4yaC0xLjRjLS4xIDAtLjIuMS0uMi4yaC0xLjRjLS4xIDAtLjIuMS0uMi4yaC0xLjRjLS4xIDAtLjIuMS0uMi4yaC0xLjRjLS4xIDAtLjIuMS0uMi4yaC0xLjRjLS4xIDAtLjIuMS0uMi4yaC0xLjRjLS4xIDAtLjI
|