Model switcher

Added model selector to swap between several different models on the fly.
This commit is contained in:
FrogAi
2024-02-27 16:34:47 -07:00
parent e076a3d4d6
commit 3345470373
11 changed files with 66 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ from typing import List, Tuple, Union
from cereal import log
import cereal.messaging as messaging
import openpilot.selfdrive.sentry as sentry
from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params, ParamKeyType
from openpilot.common.text_window import TextWindow
from openpilot.system.hardware import HARDWARE, PC
@@ -24,6 +25,7 @@ from openpilot.system.version import is_dirty, get_commit, get_version, get_orig
get_normalized_origin, terms_version, training_version, \
is_tested_branch, is_release_branch, get_commit_date
from openpilot.selfdrive.frogpilot.functions.frogpilot_functions import DEFAULT_MODEL
def manager_init() -> None:
@@ -62,6 +64,16 @@ def manager_init() -> None:
#######################################################################
# Check if the currently selected model still exists
current_model = params.get("Model", encoding='utf-8')
if current_model != DEFAULT_MODEL:
models_folder = os.path.join(BASEDIR, 'selfdrive/modeld/models/models')
model_exists = current_model in [os.path.splitext(file)[0] for file in os.listdir(models_folder)]
if not model_exists:
params.remove("Model")
default_params: List[Tuple[str, Union[str, bytes]]] = [
("CompletedTrainingVersion", "0"),
("DisengageOnAccelerator", "0"),