mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 11:23:49 +08:00
eefc084302
version: sunnypilot v2025.003.000 (dev) date: 2025-12-18T05:48:43 master commit: 16c052af0835f049a67b80251d8cc1114fc08bb4
23 lines
832 B
Python
23 lines
832 B
Python
import os
|
|
from openpilot.system.hardware import TICI
|
|
from openpilot.sunnypilot.modeld.runners.runmodel_pyx import RunModel, Runtime
|
|
assert Runtime
|
|
|
|
USE_THNEED = int(os.getenv('USE_THNEED', str(int(TICI))))
|
|
|
|
class ModelRunner(RunModel):
|
|
THNEED = 'THNEED'
|
|
ONNX = 'ONNX'
|
|
|
|
def __new__(cls, paths, *args, **kwargs):
|
|
if ModelRunner.THNEED in paths and USE_THNEED:
|
|
from openpilot.sunnypilot.modeld.runners.thneedmodel_pyx import ThneedModel as Runner
|
|
runner_type = ModelRunner.THNEED
|
|
elif ModelRunner.ONNX in paths:
|
|
from openpilot.sunnypilot.modeld.runners.onnxmodel import ONNXModel as Runner
|
|
runner_type = ModelRunner.ONNX
|
|
else:
|
|
raise Exception("Couldn't select a model runner, make sure to pass at least one valid model path")
|
|
|
|
return Runner(str(paths[runner_type]), *args, **kwargs)
|