NeuralGearheads commited on
Commit
b9e0146
ยท
verified ยท
1 Parent(s): ec2e9d0

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +4 -44
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 + TOASTS
240
  # ---------------------------
241
  def preset_daily():
242
  s = st.session_state
@@ -260,7 +260,6 @@ def preset_daily():
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,7 +283,6 @@ def preset_street():
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,7 +306,6 @@ def preset_drag():
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,7 +329,6 @@ def preset_max():
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,7 +383,7 @@ with left:
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,11 +584,6 @@ new_hp = max(base_hp + pred_total_gain, 40.0)
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,22 +596,6 @@ elif hype_level < 70:
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,7 +609,7 @@ with right:
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,22 +625,9 @@ with right:
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,9 +694,7 @@ with right:
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
 
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
  s.fuel = "87"
261
  s.altitude = 200
262
  s.traction_mode = "Daily"
 
263
 
264
  def preset_street():
265
  s = st.session_state
 
283
  s.fuel = "93"
284
  s.altitude = 150
285
  s.traction_mode = "Spirited"
 
286
 
287
  def preset_drag():
288
  s = st.session_state
 
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
  s.fuel = "E85 / Race Blend"
330
  s.altitude = 0
331
  s.traction_mode = "Track / Drag"
 
332
 
333
  # ---------------------------
334
  # HERO
 
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
  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
  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
  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
  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
  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