Aaron006 commited on
Commit
bd7353e
Β·
verified Β·
1 Parent(s): 39c3b2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -17
app.py CHANGED
@@ -6,13 +6,11 @@ import os
6
  os.environ["MPLCONFIGDIR"] = "/tmp"
7
  reg_model = joblib.load("best_vehicle_mpg_model.pkl")
8
 
9
- # Dropdown Options
10
  makes = ['FORD', 'TOYOTA', 'HONDA', 'BMW', 'AUDI']
11
  transmissions = ['Automatic', 'Manual', 'CVT', 'Auto-Manual', 'Direct Drive']
12
  fuels = ['Regular Gasoline', 'Premium Gasoline', 'Diesel', 'E85', 'CNG']
13
  classes = ['SUV', 'Compact Cars', 'Mid-size Cars', 'Large Cars', 'Pickup Trucks', 'Station Wagons']
14
 
15
- # Prediction Function
16
  def predict_mpg(year, cylinders, displ, make, trany, fuel, vclass):
17
  input_data = pd.DataFrame([{
18
  "year": year,
@@ -26,7 +24,6 @@ def predict_mpg(year, cylinders, displ, make, trany, fuel, vclass):
26
  prediction = reg_model.predict(input_data)[0]
27
  return f"πŸš— Predicted Combined MPG: {prediction:.2f} MPG"
28
 
29
- # Two Profile Cards Side by Side
30
  profile_cards = """
31
  <div style="display: flex; justify-content: center; gap: 40px; flex-wrap: wrap;">
32
  <div class="profile-card">
@@ -44,7 +41,17 @@ profile_cards = """
44
  </div>
45
  """
46
 
47
- # Custom Styling
 
 
 
 
 
 
 
 
 
 
48
  custom_css = """
49
  body { background: #0f0f1a; font-family: sans-serif; }
50
 
@@ -78,17 +85,8 @@ body { background: #0f0f1a; font-family: sans-serif; }
78
  align-self: center;
79
  }
80
 
81
- .name {
82
- font-size: 22px;
83
- color: #ffffff;
84
- margin: 6px 0;
85
- }
86
-
87
- .title {
88
- font-size: 14px;
89
- color: #ccc;
90
- margin-bottom: 16px;
91
- }
92
 
93
  .linkedin-btn {
94
  padding: 10px 16px;
@@ -98,13 +96,41 @@ body { background: #0f0f1a; font-family: sans-serif; }
98
  text-decoration: none;
99
  font-weight: bold;
100
  }
101
-
102
  .linkedin-btn:hover { background-color: #005580; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  """
104
 
105
- # Build Interface
106
  with gr.Blocks(css=custom_css) as demo:
107
  gr.HTML(profile_cards)
 
108
 
109
  gr.Markdown("## 🚘 Vehicle MPG Predictor")
110
  gr.Markdown("Enter vehicle details to predict Combined MPG")
 
6
  os.environ["MPLCONFIGDIR"] = "/tmp"
7
  reg_model = joblib.load("best_vehicle_mpg_model.pkl")
8
 
 
9
  makes = ['FORD', 'TOYOTA', 'HONDA', 'BMW', 'AUDI']
10
  transmissions = ['Automatic', 'Manual', 'CVT', 'Auto-Manual', 'Direct Drive']
11
  fuels = ['Regular Gasoline', 'Premium Gasoline', 'Diesel', 'E85', 'CNG']
12
  classes = ['SUV', 'Compact Cars', 'Mid-size Cars', 'Large Cars', 'Pickup Trucks', 'Station Wagons']
13
 
 
14
  def predict_mpg(year, cylinders, displ, make, trany, fuel, vclass):
15
  input_data = pd.DataFrame([{
16
  "year": year,
 
24
  prediction = reg_model.predict(input_data)[0]
25
  return f"πŸš— Predicted Combined MPG: {prediction:.2f} MPG"
26
 
 
27
  profile_cards = """
28
  <div style="display: flex; justify-content: center; gap: 40px; flex-wrap: wrap;">
29
  <div class="profile-card">
 
41
  </div>
42
  """
43
 
44
+ built_with = """
45
+ <div class="built-with">
46
+ <h3>πŸ”§ Built With:</h3>
47
+ <div class="badges">
48
+ <span class="badge">Python</span>
49
+ <span class="badge">scikit-learn</span>
50
+ <span class="badge">Gradio</span>
51
+ </div>
52
+ </div>
53
+ """
54
+
55
  custom_css = """
56
  body { background: #0f0f1a; font-family: sans-serif; }
57
 
 
85
  align-self: center;
86
  }
87
 
88
+ .name { font-size: 22px; color: #ffffff; margin: 6px 0; }
89
+ .title { font-size: 14px; color: #ccc; margin-bottom: 16px; }
 
 
 
 
 
 
 
 
 
90
 
91
  .linkedin-btn {
92
  padding: 10px 16px;
 
96
  text-decoration: none;
97
  font-weight: bold;
98
  }
 
99
  .linkedin-btn:hover { background-color: #005580; }
100
+
101
+ .built-with {
102
+ text-align: center;
103
+ margin-top: 10px;
104
+ margin-bottom: 30px;
105
+ color: #ccc;
106
+ }
107
+
108
+ .built-with h3 {
109
+ font-size: 18px;
110
+ color: #fff;
111
+ margin-bottom: 10px;
112
+ }
113
+
114
+ .badges {
115
+ display: flex;
116
+ justify-content: center;
117
+ gap: 12px;
118
+ flex-wrap: wrap;
119
+ }
120
+
121
+ .badge {
122
+ padding: 6px 12px;
123
+ background-color: rgba(255, 255, 255, 0.1);
124
+ border: 1px solid rgba(255, 255, 255, 0.2);
125
+ border-radius: 6px;
126
+ font-size: 13px;
127
+ color: #fff;
128
+ }
129
  """
130
 
 
131
  with gr.Blocks(css=custom_css) as demo:
132
  gr.HTML(profile_cards)
133
+ gr.HTML(built_with)
134
 
135
  gr.Markdown("## 🚘 Vehicle MPG Predictor")
136
  gr.Markdown("Enter vehicle details to predict Combined MPG")