Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -76,7 +76,8 @@ def predict_price(model, brand, model_name, year):
|
|
76 |
'age': datetime.now().year - year,
|
77 |
'age_squared': (datetime.now().year - year) ** 2,
|
78 |
'mileage_per_year': 12000,
|
79 |
-
'
|
|
|
80 |
'condition': 'Used',
|
81 |
'fuel': 'Gasoline',
|
82 |
'title_status': 'Clean',
|
@@ -149,15 +150,16 @@ if st.session_state.image is not None:
|
|
149 |
st.write(f"Model: {classification['label']}")
|
150 |
st.write(f"Confidence: {classification['score'] * 100:.2f}%")
|
151 |
|
152 |
-
#
|
153 |
top_prediction = car_classifications[0]['label']
|
154 |
-
|
155 |
|
156 |
-
st.write(f"Identified Car: {
|
|
|
157 |
|
158 |
# Get additional information using GPT-3.5-turbo
|
159 |
current_year = datetime.now().year
|
160 |
-
overview = get_car_overview(
|
161 |
st.write("Car Overview:")
|
162 |
st.write(overview)
|
163 |
|
@@ -170,13 +172,13 @@ if st.session_state.image is not None:
|
|
170 |
predicted_prices = []
|
171 |
|
172 |
for year in years:
|
173 |
-
price = predict_price(model,
|
174 |
predicted_prices.append(price)
|
175 |
|
176 |
# Plotting the results
|
177 |
plt.figure(figsize=(10, 5))
|
178 |
plt.plot(years, predicted_prices, marker='o')
|
179 |
-
plt.title(f"Predicted Price of {
|
180 |
plt.xlabel("Year")
|
181 |
plt.ylabel("Predicted Price ($)")
|
182 |
plt.grid()
|
|
|
76 |
'age': datetime.now().year - year,
|
77 |
'age_squared': (datetime.now().year - year) ** 2,
|
78 |
'mileage_per_year': 12000,
|
79 |
+
'make': brand, # Use the separated make
|
80 |
+
'model': model_name, # Use the separated model
|
81 |
'condition': 'Used',
|
82 |
'fuel': 'Gasoline',
|
83 |
'title_status': 'Clean',
|
|
|
150 |
st.write(f"Model: {classification['label']}")
|
151 |
st.write(f"Confidence: {classification['score'] * 100:.2f}%")
|
152 |
|
153 |
+
# Separate make and model from the classification result
|
154 |
top_prediction = car_classifications[0]['label']
|
155 |
+
make_name, model_name = top_prediction.split(' ', 1)
|
156 |
|
157 |
+
st.write(f"Identified Car Make: {make_name}")
|
158 |
+
st.write(f"Identified Car Model: {model_name}")
|
159 |
|
160 |
# Get additional information using GPT-3.5-turbo
|
161 |
current_year = datetime.now().year
|
162 |
+
overview = get_car_overview(make_name, model_name, current_year)
|
163 |
st.write("Car Overview:")
|
164 |
st.write(overview)
|
165 |
|
|
|
172 |
predicted_prices = []
|
173 |
|
174 |
for year in years:
|
175 |
+
price = predict_price(model, make_name, model_name, year)
|
176 |
predicted_prices.append(price)
|
177 |
|
178 |
# Plotting the results
|
179 |
plt.figure(figsize=(10, 5))
|
180 |
plt.plot(years, predicted_prices, marker='o')
|
181 |
+
plt.title(f"Predicted Price of {make_name} {model_name} Over Time")
|
182 |
plt.xlabel("Year")
|
183 |
plt.ylabel("Predicted Price ($)")
|
184 |
plt.grid()
|