NeuralGearheads commited on
Commit
ec2e9d0
Β·
verified Β·
1 Parent(s): 9c6d73d

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +44 -4
src/streamlit_app.py CHANGED
@@ -236,7 +236,7 @@ model = KNeighborsRegressor(n_neighbors=5, weights="distance")
236
  model.fit(X_scaled, y)
237
 
238
  # ---------------------------
239
- # PRESET CALLBACKS (use session_state)
240
  # ---------------------------
241
  def preset_daily():
242
  s = st.session_state
@@ -260,6 +260,7 @@ def preset_daily():
260
  s.fuel = "87"
261
  s.altitude = 200
262
  s.traction_mode = "Daily"
 
263
 
264
  def preset_street():
265
  s = st.session_state
@@ -283,6 +284,7 @@ def preset_street():
283
  s.fuel = "93"
284
  s.altitude = 150
285
  s.traction_mode = "Spirited"
 
286
 
287
  def preset_drag():
288
  s = st.session_state
@@ -306,6 +308,7 @@ def preset_drag():
306
  s.fuel = "E85 / Race Blend"
307
  s.altitude = 100
308
  s.traction_mode = "Track / Drag"
 
309
 
310
  def preset_max():
311
  s = st.session_state
@@ -329,6 +332,7 @@ def preset_max():
329
  s.fuel = "E85 / Race Blend"
330
  s.altitude = 0
331
  s.traction_mode = "Track / Drag"
 
332
 
333
  # ---------------------------
334
  # HERO
@@ -383,7 +387,7 @@ with left:
383
  st.markdown('<div class="glass">', unsafe_allow_html=True)
384
  st.subheader("πŸŽ›οΈ Tune Your Build")
385
 
386
- # Preset buttons
387
  bcol1, bcol2, bcol3, bcol4 = st.columns(4)
388
  bcol1.button("πŸš™ Daily Driver", on_click=preset_daily)
389
  bcol2.button("πŸŒƒ Street Fun", on_click=preset_street)
@@ -584,6 +588,11 @@ new_hp = max(base_hp + pred_total_gain, 40.0)
584
  effective_weight = weight_kg * (1 - weight_reduction / 100.0)
585
  hp_per_ton = new_hp / (effective_weight / 1000.0)
586
 
 
 
 
 
 
587
  hype_raw = np.clip(pred_total_gain / 120 * 100, 0, 100)
588
  hype_level = int(hype_raw)
589
 
@@ -596,6 +605,22 @@ elif hype_level < 70:
596
  else:
597
  verdict = "Full send, tyres cry for mercy 🏁"
598
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  # compute base angle for rev gauge (-90deg to +90deg)
600
  angle_deg = -90 + (hype_level / 100.0) * 180
601
 
@@ -609,7 +634,7 @@ with right:
609
  m2.metric("New Output", f"{new_hp:.1f} HP")
610
  m3.metric("HP per Ton", f"{hp_per_ton:.1f}")
611
 
612
- # Animated rev limiter gauge
613
  st.markdown('<div class="meter-label">Rev Limiter Vibes</div>', unsafe_allow_html=True)
614
  st.markdown(
615
  f"""
@@ -625,9 +650,22 @@ with right:
625
  unsafe_allow_html=True
626
  )
627
 
 
628
  st.markdown('<div class="meter-label">Hype Meter (relative craziness of this build)</div>', unsafe_allow_html=True)
629
  st.progress(hype_level)
630
  st.markdown(f"**Verdict:** {verdict}")
 
 
 
 
 
 
 
 
 
 
 
 
631
 
632
  st.markdown("")
633
  st.bar_chart(
@@ -694,7 +732,9 @@ with right:
694
  st.markdown(
695
  """
696
  <div style="text-align:center;margin-top:10px;" class="muted">
697
- Presets + rev limiter + neon dyno… if this doesn’t make people go mad, we can push it even further. πŸ”§πŸ”₯
 
 
698
  </div>
699
  """,
700
  unsafe_allow_html=True
 
236
  model.fit(X_scaled, y)
237
 
238
  # ---------------------------
239
+ # PRESET CALLBACKS + TOASTS
240
  # ---------------------------
241
  def preset_daily():
242
  s = st.session_state
 
260
  s.fuel = "87"
261
  s.altitude = 200
262
  s.traction_mode = "Daily"
263
+ st.toast("Loaded Daily Driver preset πŸš™")
264
 
265
  def preset_street():
266
  s = st.session_state
 
284
  s.fuel = "93"
285
  s.altitude = 150
286
  s.traction_mode = "Spirited"
287
+ st.toast("Loaded Street Fun preset πŸŒƒ")
288
 
289
  def preset_drag():
290
  s = st.session_state
 
308
  s.fuel = "E85 / Race Blend"
309
  s.altitude = 100
310
  s.traction_mode = "Track / Drag"
311
+ st.toast("Loaded Drag Strip preset 🏁")
312
 
313
  def preset_max():
314
  s = st.session_state
 
332
  s.fuel = "E85 / Race Blend"
333
  s.altitude = 0
334
  s.traction_mode = "Track / Drag"
335
+ st.toast("Loaded Max Attack preset πŸ”₯")
336
 
337
  # ---------------------------
338
  # HERO
 
387
  st.markdown('<div class="glass">', unsafe_allow_html=True)
388
  st.subheader("πŸŽ›οΈ Tune Your Build")
389
 
390
+ # Preset buttons with toasts
391
  bcol1, bcol2, bcol3, bcol4 = st.columns(4)
392
  bcol1.button("πŸš™ Daily Driver", on_click=preset_daily)
393
  bcol2.button("πŸŒƒ Street Fun", on_click=preset_street)
 
588
  effective_weight = weight_kg * (1 - weight_reduction / 100.0)
589
  hp_per_ton = new_hp / (effective_weight / 1000.0)
590
 
591
+ # 0–100 km/h & 1/4-mile simple estimates (rule-of-thumb)
592
+ zero_to_100 = max(2.8, 12 - (hp_per_ton - 80) / 20) # lower is faster
593
+ quarter_mile = max(9.0, 18 - (hp_per_ton - 80) / 15) # lower is faster
594
+
595
+ # hype + verdict
596
  hype_raw = np.clip(pred_total_gain / 120 * 100, 0, 100)
597
  hype_level = int(hype_raw)
598
 
 
605
  else:
606
  verdict = "Full send, tyres cry for mercy 🏁"
607
 
608
+ # Scenario hint (simple rule-based label)
609
+ if induction == "None":
610
+ if base_hp < 180:
611
+ extra_hint = "+60–80 hp"
612
+ elif base_hp < 320:
613
+ extra_hint = "+80–110 hp"
614
+ else:
615
+ extra_hint = "+100–150 hp"
616
+ scenario_hint = f"Try adding a **Turbo** + **Stage 1 tune** on {fuel} for around {extra_hint} more."
617
+ elif tune in ["None", "Mild Street"]:
618
+ scenario_hint = "Bump to **Stage 2** tune and a slightly higher boost target for a big jump."
619
+ elif fuel != "E85 / Race Blend":
620
+ scenario_hint = "Switching to **E85 / race blend** with proper tuning could unlock extra timing and power."
621
+ else:
622
+ scenario_hint = "You’re near kill mode already – consider better tyres, brakes and cooling instead of more power. πŸ˜‰"
623
+
624
  # compute base angle for rev gauge (-90deg to +90deg)
625
  angle_deg = -90 + (hype_level / 100.0) * 180
626
 
 
634
  m2.metric("New Output", f"{new_hp:.1f} HP")
635
  m3.metric("HP per Ton", f"{hp_per_ton:.1f}")
636
 
637
+ # Rev limiter gauge
638
  st.markdown('<div class="meter-label">Rev Limiter Vibes</div>', unsafe_allow_html=True)
639
  st.markdown(
640
  f"""
 
650
  unsafe_allow_html=True
651
  )
652
 
653
+ # Hype meter + scenario label
654
  st.markdown('<div class="meter-label">Hype Meter (relative craziness of this build)</div>', unsafe_allow_html=True)
655
  st.progress(hype_level)
656
  st.markdown(f"**Verdict:** {verdict}")
657
+ st.markdown(f"πŸ’‘ **Hint:** {scenario_hint}")
658
+
659
+ # Acceleration estimates
660
+ st.markdown(
661
+ f"""
662
+ <div style="margin-top:6px;margin-bottom:4px;">
663
+ <span class="chip">0–100 km/h β‰ˆ {zero_to_100:.1f} s</span>
664
+ <span class="chip">ΒΌ mile β‰ˆ {quarter_mile:.1f} s</span>
665
+ </div>
666
+ """,
667
+ unsafe_allow_html=True
668
+ )
669
 
670
  st.markdown("")
671
  st.bar_chart(
 
732
  st.markdown(
733
  """
734
  <div style="text-align:center;margin-top:10px;" class="muted">
735
+ For truly crazy UI (SVG rev gauges, 3D cars, cinema animations),
736
+ this logic can be plugged into a React/Next.js front-end with Framer Motion,
737
+ keeping Python as the ML API. For Streamlit though… this is already pretty wild. πŸ”§πŸ”₯
738
  </div>
739
  """,
740
  unsafe_allow_html=True