MCPcopy Index your code
hub / github.com/mudler/LocalAI / LoadModel

Method LoadModel

backend/python/insightface/backend.py:73–99  ·  view source on GitHub ↗
(self, request, context)

Source from the content-addressed store, hash-verified

71 return backend_pb2.Reply(message=bytes("OK", "utf-8"))
72
73 def LoadModel(self, request, context):
74 options = _parse_options(list(request.Options))
75 # Surface LocalAI's models directory (ModelPath) so engines can
76 # anchor relative paths — OnnxDirectEngine's detector_onnx /
77 # recognizer_onnx point at gallery-managed files that LocalAI
78 # dropped there, and InsightFaceEngine auto-downloads its packs
79 # into that same directory alongside every other managed model.
80 # Private key to avoid clashing with user-provided options.
81 if request.ModelPath:
82 options["_model_dir"] = request.ModelPath
83
84 engine_name = options.get("engine", "insightface")
85 try:
86 self.engine = build_engine(engine_name)
87 self.engine.prepare(options)
88 except Exception as err: # pragma: no cover - exercised via e2e
89 return backend_pb2.Result(success=False, message=f"Failed to load face engine: {err}")
90
91 self.engine_name = engine_name
92 self.model_name = request.Model or options.get("model_pack", "")
93 if "verify_threshold" in options:
94 try:
95 self.verify_threshold = float(options["verify_threshold"])
96 except ValueError:
97 pass
98 print(f"[insightface] engine={engine_name} model={self.model_name} loaded", file=sys.stderr)
99 return backend_pb2.Result(success=True, message="Model loaded successfully")
100
101 def Status(self, request, context):
102 state = (

Callers 1

_run_oneFunction · 0.95

Calls 4

build_engineFunction · 0.90
_parse_optionsFunction · 0.70
getMethod · 0.45
prepareMethod · 0.45

Tested by

no test coverage detected