Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NNFF: use substitute.toml for fallback model lookup #224

Open
wants to merge 1 commit into
base: MAKE-PRS-HERE
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,29 @@ def check_nn_path(check_model):
model_path = os.path.join(TORQUE_NN_MODEL_PATH, f)
return model_path, max_similarity

if len(eps_firmware) > 3:
eps_firmware = eps_firmware.replace("\\", "")
check_model = f"{car} {eps_firmware}"
else:
check_model = car
model_path, max_similarity = check_nn_path(check_model)
if car not in model_path or 0.0 <= max_similarity < 0.9:
check_model = car
def check_candidate(car, eps_firmware):
if len(eps_firmware) > 3:
eps_firmware = eps_firmware.replace("\\", "")
check_model = f"{car} {eps_firmware}"
else:
check_model = car
model_path, max_similarity = check_nn_path(check_model)
if car not in model_path or 0.0 <= max_similarity < 0.9:
model_path = None
return model_path
check_model = car
model_path, max_similarity = check_nn_path(check_model)
if car not in model_path or 0.0 <= max_similarity < 0.9:
model_path = None
return model_path, max_similarity

with open(TORQUE_SUBSTITUTE_PATH, 'rb') as f:
sub = tomllib.load(f)
sub_candidate = sub.get(car, car)

for candidate in [car, sub_candidate]:
model, similarity_score = check_candidate(candidate, eps_firmware)
if model is not None:
return model
return None

def get_nn_model(car, eps_firmware) -> tuple[FluxModel | None, float]:
model = get_nn_model_path(car, eps_firmware)
Expand Down
Loading