SHELLAPANDIANGANHUNGING commited on
Commit
0e0a26a
Β·
verified Β·
1 Parent(s): a82b5e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -5
app.py CHANGED
@@ -39,7 +39,6 @@ def calculate_pressure(tyre_type, temp, condition, min_max):
39
 
40
  # ================= CUSTOM CSS (Dark Theme Premium) =================
41
  custom_css = """
42
- <style>
43
  body {
44
  background: #000000;
45
  color: #ffffff;
@@ -115,11 +114,64 @@ button:hover {
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  # ================= CUSTOM CSS (Dark Theme Premium) =================
41
  custom_css = """
 
42
  body {
43
  background: #000000;
44
  color: #ffffff;
 
114
  color: #FF0000;
115
  font-weight: bold;
116
  }
 
117
  """
118
 
119
  # ================= GRADIO INTERFACE =================
120
  with gr.Blocks(title="Michelin Mining Tyre Analytics β€” Objective 6", css=custom_css) as demo:
121
+ gr.Markdown("""
122
+ # πŸ›ž Michelin Mining Tyre Analytics β€” Objective 6
123
+ ### Simulasi Tekanan Ban Berdasarkan Suhu & Jenis Ban
124
+ Masukkan suhu saat ini dan pilih jenis ban untuk mendapatkan rekomendasi tekanan ideal.
125
+ """)
126
+
127
+ with gr.Row():
128
+ tyre_type = gr.Radio(
129
+ choices=["10 (Depan)", "11 (Belakang)"],
130
+ label="Jenis Ban",
131
+ value="10 (Depan)",
132
+ interactive=True
133
+ )
134
+ temperature = gr.Slider(
135
+ minimum=40,
136
+ maximum=70,
137
+ value=54,
138
+ step=0.5,
139
+ label="Suhu Saat Ini (Β°C)",
140
+ interactive=True
141
+ )
142
+
143
+ with gr.Row():
144
+ btn_simulate = gr.Button("πŸ” Simulasikan Tekanan")
145
+
146
+ with gr.Row():
147
+ output = gr.HTML(label="Hasil Simulasi")
148
+
149
+ def simulate_pressure(tyres, temp):
150
+ tyre_num = int(tyres.split()[0])
151
+ p_min_high = calculate_pressure(tyre_num, temp, 'High', 'Min')
152
+ p_max_high = calculate_pressure(tyre_num, temp, 'High', 'Max')
153
+ p_min_low = calculate_pressure(tyre_num, temp, 'Low', 'Min')
154
+ p_max_low = calculate_pressure(tyre_num, temp, 'Low', 'Max')
155
+
156
+ if p_min_high is None or p_max_high is None or p_min_low is None or p_max_low is None:
157
+ return "<p style='color:#FF0000;'>❌ Tidak dapat menghitung tekanan. Periksa input.</p>"
158
+
159
+ # Rekomendasi: Jaga tekanan antara P Min Low dan P Max High
160
+ recommendation = f"""
161
+ <div class="output-area">
162
+ <h4>πŸ“Š Hasil Simulasi untuk Ban {tyres} pada Suhu {temp}Β°C</h4>
163
+ <p><strong>P Min saat Low Pressure:</strong> <span style="color:#FFD100;">{p_min_low:.1f} psi</span></p>
164
+ <p><strong>P Max saat Low Pressure:</strong> <span style="color:#FFD100;">{p_max_low:.1f} psi</span></p>
165
+ <p><strong>P Min saat High Pressure:</strong> <span style="color:#FFD100;">{p_min_high:.1f} psi</span></p>
166
+ <p><strong>P Max saat High Pressure:</strong> <span style="color:#FFD100;">{p_max_high:.1f} psi</span></p>
167
+ <hr>
168
+ <p class="recommendation">βœ… Rekomendasi Tekanan Ideal:</strong> Isi angin antara <strong>{p_min_low:.1f} – {p_max_high:.1f} psi</strong> untuk menghindari alarm Amber/Red.</p>
169
+ <p class="warning">⚠️ Jika tekanan saat ini < {p_min_low:.1f} psi β†’ risiko <strong>Low Pressure</strong>.</p>
170
+ <p class="danger">⚠️ Jika tekanan saat ini > {p_max_high:.1f} psi β†’ risiko <strong>High Pressure</strong>.</p>
171
+ </div>
172
+ """
173
+ return recommendation
174
+
175
+ btn_simulate.click(simulate_pressure, inputs=[tyre_type, temperature], outputs=output)
176
+
177
+ demo.launch()