From 92e8ef1d491129b5e0587f550bf8a84c9936cedf Mon Sep 17 00:00:00 2001 From: infiniteCable2 Date: Thu, 23 Jul 2026 20:04:06 +0200 Subject: [PATCH] load model from comma during build --- .lfsconfig | 1 + openpilot/selfdrive/modeld/SConscript | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.lfsconfig b/.lfsconfig index 4375f2ec7..7d1433ffb 100644 --- a/.lfsconfig +++ b/.lfsconfig @@ -2,3 +2,4 @@ url = https://gitlab.com/sunnypilot/public/sunnypilot-new-lfs.git/info/lfs pushurl = ssh://git@gitlab.com/sunnypilot/public/sunnypilot-new-lfs.git locksverify = false + fetchexclude = openpilot/selfdrive/modeld/models/driving_supercombo.onnx diff --git a/openpilot/selfdrive/modeld/SConscript b/openpilot/selfdrive/modeld/SConscript index 5f6281556..ace1467c4 100644 --- a/openpilot/selfdrive/modeld/SConscript +++ b/openpilot/selfdrive/modeld/SConscript @@ -84,6 +84,20 @@ compile_modeld_script = [ model_w, model_h = MEDMODEL_INPUT_SIZE frame_skip = ModelConstants.MODEL_RUN_FREQ // ModelConstants.MODEL_CONTEXT_FREQ +default_driving_onnx = File("models/driving_supercombo.onnx").abspath +with open(default_driving_onnx, "rb") as f: + default_model_is_lfs_pointer = f.read(200).startswith(b"version https://git-lfs.github.com/spec/v1") + +if default_model_is_lfs_pointer: + default_model_relpath = os.path.relpath(default_driving_onnx, env.Dir("#").abspath).replace(os.sep, "/") + subprocess.run([ + "git", "-c", "lfs.url=https://gitlab.com/commaai/openpilot-lfs.git/info/lfs", + "lfs", "pull", f"--include={default_model_relpath}", "--exclude=", + ], cwd=env.Dir("#").abspath, check=True) + with open(default_driving_onnx, "rb") as f: + if f.read(200).startswith(b"version https://git-lfs.github.com/spec/v1"): + raise RuntimeError("Failed to download the default driving model from comma LFS") + for usbgpu in [False, True] if USBGPU else [False]: target_pkl_path = File(modeld_pkl_path(usbgpu)).abspath # BIG_INTO_SMALL=1 builds the default target from the big model, e.g. to test it without a USB GPU