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

Class _Harness

backend/python/insightface/test.py:120–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118
119
120class _Harness:
121 def __init__(self, servicer: BackendServicer) -> None:
122 self.svc = servicer
123
124 def health(self):
125 return self.svc.Health(backend_pb2.HealthMessage(), _FakeContext())
126
127 def load(self, options: list[str], model_path: str = ""):
128 return self.svc.LoadModel(
129 backend_pb2.ModelOptions(Model="test", Options=options, ModelPath=model_path),
130 _FakeContext(),
131 )
132
133 def detect(self, img_b64: str):
134 return self.svc.Detect(backend_pb2.DetectOptions(src=img_b64), _FakeContext())
135
136 def embed(self, img_b64: str):
137 ctx = _FakeContext()
138 res = self.svc.Embedding(
139 backend_pb2.PredictOptions(Images=[img_b64]),
140 ctx,
141 )
142 return res, ctx
143
144 def verify(self, a: str, b: str, threshold: float = 0.0, anti_spoofing: bool = False):
145 ctx = _FakeContext()
146 res = self.svc.FaceVerify(
147 backend_pb2.FaceVerifyRequest(
148 img1=a, img2=b, threshold=threshold, anti_spoofing=anti_spoofing
149 ),
150 ctx,
151 )
152 return res, ctx
153
154 def analyze(self, img_b64: str, anti_spoofing: bool = False):
155 ctx = _FakeContext()
156 res = self.svc.FaceAnalyze(
157 backend_pb2.FaceAnalyzeRequest(img=img_b64, anti_spoofing=anti_spoofing),
158 ctx,
159 )
160 return res, ctx
161
162
163class InsightFaceEngineTest(unittest.TestCase):

Callers 3

setUpClassMethod · 0.85
setUpClassMethod · 0.85
setUpClassMethod · 0.85

Calls

no outgoing calls

Tested by 3

setUpClassMethod · 0.68
setUpClassMethod · 0.68
setUpClassMethod · 0.68