mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Use cpu provider for embeddings models (#13806)
This commit is contained in:
parent
ff9e1da1de
commit
e44a9e8921
@ -49,31 +49,11 @@ class Clip(OnnxClip):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _load_model(path: str, silent: bool):
|
def _load_model(path: str, silent: bool):
|
||||||
providers = []
|
providers = ["CPUExecutionProvider"]
|
||||||
options = []
|
|
||||||
|
|
||||||
for provider in ort.get_available_providers():
|
|
||||||
if provider == "TensorrtExecutionProvider":
|
|
||||||
continue
|
|
||||||
elif provider == "OpenVINOExecutionProvider":
|
|
||||||
# TODO need to verify openvino works correctly
|
|
||||||
os.makedirs("/config/model_cache/openvino/ort", exist_ok=True)
|
|
||||||
providers.append(provider)
|
|
||||||
options.append(
|
|
||||||
{
|
|
||||||
"cache_dir": "/config/model_cache/openvino/ort",
|
|
||||||
"device_type": "GPU",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
providers.append(provider)
|
|
||||||
options.append({})
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
return ort.InferenceSession(
|
return ort.InferenceSession(path, providers=providers)
|
||||||
path, providers=providers, provider_options=options
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
errno.ENOENT,
|
errno.ENOENT,
|
||||||
@ -104,9 +84,7 @@ class Clip(OnnxClip):
|
|||||||
f.flush()
|
f.flush()
|
||||||
# Finally move the temporary file to the correct location
|
# Finally move the temporary file to the correct location
|
||||||
temporary_filename.rename(path)
|
temporary_filename.rename(path)
|
||||||
return ort.InferenceSession(
|
return ort.InferenceSession(path, providers=providers)
|
||||||
path, providers=provider, provider_options=options
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ClipEmbedding(EmbeddingFunction):
|
class ClipEmbedding(EmbeddingFunction):
|
||||||
|
Loading…
Reference in New Issue
Block a user