Update app.py
Browse files
app.py
CHANGED
@@ -247,7 +247,7 @@ def analyze_aerodynamics():
|
|
247 |
def predict_performance(front_wing, rear_wing, ride_height, suspension, downforce, drag_coeff, track_temp, wind_speed, track_grip):
|
248 |
"""Predict lap time for given setup"""
|
249 |
if not predictor.is_trained:
|
250 |
-
return "
|
251 |
|
252 |
setup_params = [front_wing, rear_wing, ride_height, suspension, downforce, drag_coeff, track_temp, wind_speed, track_grip]
|
253 |
lap_time = predictor.predict_lap_time(setup_params)
|
@@ -257,18 +257,18 @@ def predict_performance(front_wing, rear_wing, ride_height, suspension, downforc
|
|
257 |
def optimize_car_setup(track_temp, wind_speed, track_grip):
|
258 |
"""Optimize car setup for given conditions"""
|
259 |
if not predictor.is_trained:
|
260 |
-
return "
|
261 |
|
262 |
track_conditions = [track_temp, wind_speed, track_grip]
|
263 |
result = predictor.optimize_setup(track_conditions)
|
264 |
|
265 |
if result is None:
|
266 |
-
return "
|
267 |
|
268 |
optimal_setup, optimal_lap_time = result
|
269 |
|
270 |
setup_report = f"""
|
271 |
-
##
|
272 |
|
273 |
**Predicted Lap Time: {optimal_lap_time:.3f} seconds**
|
274 |
|
@@ -290,10 +290,10 @@ def optimize_car_setup(track_temp, wind_speed, track_grip):
|
|
290 |
|
291 |
# Create Gradio interface
|
292 |
with gr.Blocks(title="F1 Aerodynamic Performance Predictor", theme=gr.themes.Soft()) as demo:
|
293 |
-
gr.Markdown("#
|
294 |
gr.Markdown("AI-powered aerodynamic analysis and setup optimization for Formula 1 racing.")
|
295 |
|
296 |
-
with gr.Tab("
|
297 |
gr.Markdown("### Analyze aerodynamic performance data")
|
298 |
analyze_btn = gr.Button("π Analyze Aerodynamics", variant="primary")
|
299 |
|
@@ -308,7 +308,7 @@ with gr.Blocks(title="F1 Aerodynamic Performance Predictor", theme=gr.themes.Sof
|
|
308 |
outputs=[aero_plot, aero_report]
|
309 |
)
|
310 |
|
311 |
-
with gr.Tab("
|
312 |
gr.Markdown("### Predict lap time for specific setup")
|
313 |
gr.Markdown("*Note: Run the analysis first to train the model*")
|
314 |
|
@@ -339,7 +339,7 @@ with gr.Blocks(title="F1 Aerodynamic Performance Predictor", theme=gr.themes.Sof
|
|
339 |
outputs=[lap_time_output]
|
340 |
)
|
341 |
|
342 |
-
with gr.Tab("
|
343 |
gr.Markdown("### Optimize car setup for track conditions")
|
344 |
gr.Markdown("*Uses genetic algorithm to find optimal aerodynamic configuration*")
|
345 |
|
@@ -361,13 +361,13 @@ with gr.Blocks(title="F1 Aerodynamic Performance Predictor", theme=gr.themes.Sof
|
|
361 |
outputs=[optimization_output]
|
362 |
)
|
363 |
|
364 |
-
with gr.Tab("
|
365 |
gr.Markdown("""
|
366 |
## About This Tool
|
367 |
|
368 |
This F1 Aerodynamic Performance Predictor uses advanced machine learning and optimization techniques:
|
369 |
|
370 |
-
|
371 |
- Random Forest model predicts lap times based on car setup and track conditions
|
372 |
- Considers aerodynamic efficiency, wing configurations, and environmental factors
|
373 |
- Trained on realistic F1 aerodynamic data
|
@@ -377,19 +377,19 @@ with gr.Blocks(title="F1 Aerodynamic Performance Predictor", theme=gr.themes.Sof
|
|
377 |
- Balances downforce vs drag for maximum performance
|
378 |
- Considers track-specific conditions for tailored setups
|
379 |
|
380 |
-
|
381 |
- Aerodynamic efficiency analysis (downforce/drag ratio)
|
382 |
- Wing angle optimization for different track types
|
383 |
- Environmental impact assessment (temperature, wind, grip)
|
384 |
- Sensitivity analysis for setup parameters
|
385 |
|
386 |
-
|
387 |
- Random Forest Regressor for non-linear relationships
|
388 |
- Differential Evolution for global optimization
|
389 |
- StandardScaler for feature normalization
|
390 |
- Advanced visualization of aerodynamic trade-offs
|
391 |
|
392 |
-
|
393 |
- Pre-race setup optimization
|
394 |
- Strategy planning for different track conditions
|
395 |
- Understanding aerodynamic trade-offs
|
|
|
247 |
def predict_performance(front_wing, rear_wing, ride_height, suspension, downforce, drag_coeff, track_temp, wind_speed, track_grip):
|
248 |
"""Predict lap time for given setup"""
|
249 |
if not predictor.is_trained:
|
250 |
+
return "Please run the analysis first to train the model!"
|
251 |
|
252 |
setup_params = [front_wing, rear_wing, ride_height, suspension, downforce, drag_coeff, track_temp, wind_speed, track_grip]
|
253 |
lap_time = predictor.predict_lap_time(setup_params)
|
|
|
257 |
def optimize_car_setup(track_temp, wind_speed, track_grip):
|
258 |
"""Optimize car setup for given conditions"""
|
259 |
if not predictor.is_trained:
|
260 |
+
return "Please run the analysis first to train the model!"
|
261 |
|
262 |
track_conditions = [track_temp, wind_speed, track_grip]
|
263 |
result = predictor.optimize_setup(track_conditions)
|
264 |
|
265 |
if result is None:
|
266 |
+
return "Optimization failed"
|
267 |
|
268 |
optimal_setup, optimal_lap_time = result
|
269 |
|
270 |
setup_report = f"""
|
271 |
+
## Optimal Car Setup
|
272 |
|
273 |
**Predicted Lap Time: {optimal_lap_time:.3f} seconds**
|
274 |
|
|
|
290 |
|
291 |
# Create Gradio interface
|
292 |
with gr.Blocks(title="F1 Aerodynamic Performance Predictor", theme=gr.themes.Soft()) as demo:
|
293 |
+
gr.Markdown("# F1 Aerodynamic Performance Predictor")
|
294 |
gr.Markdown("AI-powered aerodynamic analysis and setup optimization for Formula 1 racing.")
|
295 |
|
296 |
+
with gr.Tab("Aerodynamic Analysis"):
|
297 |
gr.Markdown("### Analyze aerodynamic performance data")
|
298 |
analyze_btn = gr.Button("π Analyze Aerodynamics", variant="primary")
|
299 |
|
|
|
308 |
outputs=[aero_plot, aero_report]
|
309 |
)
|
310 |
|
311 |
+
with gr.Tab("Performance Prediction"):
|
312 |
gr.Markdown("### Predict lap time for specific setup")
|
313 |
gr.Markdown("*Note: Run the analysis first to train the model*")
|
314 |
|
|
|
339 |
outputs=[lap_time_output]
|
340 |
)
|
341 |
|
342 |
+
with gr.Tab("Setup Optimization"):
|
343 |
gr.Markdown("### Optimize car setup for track conditions")
|
344 |
gr.Markdown("*Uses genetic algorithm to find optimal aerodynamic configuration*")
|
345 |
|
|
|
361 |
outputs=[optimization_output]
|
362 |
)
|
363 |
|
364 |
+
with gr.Tab("About"):
|
365 |
gr.Markdown("""
|
366 |
## About This Tool
|
367 |
|
368 |
This F1 Aerodynamic Performance Predictor uses advanced machine learning and optimization techniques:
|
369 |
|
370 |
+
**Performance Prediction:**
|
371 |
- Random Forest model predicts lap times based on car setup and track conditions
|
372 |
- Considers aerodynamic efficiency, wing configurations, and environmental factors
|
373 |
- Trained on realistic F1 aerodynamic data
|
|
|
377 |
- Balances downforce vs drag for maximum performance
|
378 |
- Considers track-specific conditions for tailored setups
|
379 |
|
380 |
+
**Key Features:**
|
381 |
- Aerodynamic efficiency analysis (downforce/drag ratio)
|
382 |
- Wing angle optimization for different track types
|
383 |
- Environmental impact assessment (temperature, wind, grip)
|
384 |
- Sensitivity analysis for setup parameters
|
385 |
|
386 |
+
**Technical Implementation:**
|
387 |
- Random Forest Regressor for non-linear relationships
|
388 |
- Differential Evolution for global optimization
|
389 |
- StandardScaler for feature normalization
|
390 |
- Advanced visualization of aerodynamic trade-offs
|
391 |
|
392 |
+
**Racing Applications:**
|
393 |
- Pre-race setup optimization
|
394 |
- Strategy planning for different track conditions
|
395 |
- Understanding aerodynamic trade-offs
|