Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ from typing import Any
|
|
| 9 |
import gradio as gr
|
| 10 |
|
| 11 |
from src.price_predictor import predict_price
|
|
|
|
| 12 |
from src.recommendation_engine import generate_recommendation
|
| 13 |
from src.utils import format_currency_chf, to_float
|
| 14 |
from src.vision_analyzer import analyze_car_image
|
|
@@ -183,14 +184,20 @@ def _run_advisor(
|
|
| 183 |
age = _normalize_age(car_age_years, "Age")
|
| 184 |
make_model_input = make_model.strip() if make_model and make_model.strip() else predicted_class
|
| 185 |
|
| 186 |
-
# For
|
|
|
|
| 187 |
price_input = {
|
| 188 |
"make_model": make_model_input,
|
| 189 |
-
"body_type":
|
| 190 |
"km": to_float(mileage_km, 80000),
|
| 191 |
"age": age,
|
| 192 |
}
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
user_inputs = {
|
| 196 |
"budget_chf": to_float(budget_chf, 0),
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
|
| 11 |
from src.price_predictor import predict_price
|
| 12 |
+
from src import price_predictor
|
| 13 |
from src.recommendation_engine import generate_recommendation
|
| 14 |
from src.utils import format_currency_chf, to_float
|
| 15 |
from src.vision_analyzer import analyze_car_image
|
|
|
|
| 184 |
age = _normalize_age(car_age_years, "Age")
|
| 185 |
make_model_input = make_model.strip() if make_model and make_model.strip() else predicted_class
|
| 186 |
|
| 187 |
+
# For manual input without image, use heuristic (ML model needs too many features we don't have)
|
| 188 |
+
# For image-based input, use ML model if available
|
| 189 |
price_input = {
|
| 190 |
"make_model": make_model_input,
|
| 191 |
+
"body_type": predicted_class if vision_results.get("method") != "manual_input" else None,
|
| 192 |
"km": to_float(mileage_km, 80000),
|
| 193 |
"age": age,
|
| 194 |
}
|
| 195 |
+
|
| 196 |
+
# If manual input (no vision results), use heuristic directly to get brand-aware pricing
|
| 197 |
+
if vision_results.get("method") == "manual_input":
|
| 198 |
+
price_prediction = price_predictor._heuristic_estimate(price_input)
|
| 199 |
+
else:
|
| 200 |
+
price_prediction = predict_price(price_input)
|
| 201 |
|
| 202 |
user_inputs = {
|
| 203 |
"budget_chf": to_float(budget_chf, 0),
|