Skip to content

Commit f349fe2

Browse files
committed
immich_ml 服务器运行成功
1 parent d4f2b43 commit f349fe2

19 files changed

Lines changed: 1668 additions & 7 deletions

machine-learning/immich_ml/models/base.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import immich_ml.sessions.ann.loader
1111
import immich_ml.sessions.rknn as rknn
1212
from immich_ml.sessions.ort import OrtSession
13+
from immich_ml.sessions.axengine import InferenceSession as AXSession
1314

1415
from ..config import clean_name, log, settings
1516
from ..schemas import ModelFormat, ModelIdentity, ModelSession, ModelTask, ModelType
@@ -72,13 +73,15 @@ def _download(self) -> None:
7273
ModelFormat.ARMNN: ["*.rknn"],
7374
ModelFormat.RKNN: ["*.armnn"],
7475
}
75-
76-
snapshot_download(
77-
f"immich-app/{clean_name(self.model_name)}",
78-
cache_dir=self.cache_dir,
79-
local_dir=self.cache_dir,
80-
ignore_patterns=ignored_patterns.get(self.model_format, []),
81-
)
76+
if 'axera' in self.model_name:
77+
self.model_format = ModelFormat.AXERA
78+
else:
79+
snapshot_download(
80+
f"immich-app/{clean_name(self.model_name)}",
81+
cache_dir=self.cache_dir,
82+
local_dir=self.cache_dir,
83+
ignore_patterns=ignored_patterns.get(self.model_format, []),
84+
)
8285

8386
def _load(self) -> ModelSession:
8487
return self._make_session(self.model_path)
@@ -116,6 +119,8 @@ def _make_session(self, model_path: Path) -> ModelSession:
116119
session = OrtSession(model_path)
117120
case ".rknn":
118121
session = rknn.RknnSession(model_path)
122+
case ".axmodel":
123+
session = AXSession(str(model_path))
119124
case _:
120125
raise ValueError(f"Unsupported model file type: {model_path.suffix}")
121126
return session

machine-learning/immich_ml/models/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"ViT-H-14-quickgelu__dfn5b",
3030
"ViT-H-14__laion2b-s32b-b79k",
3131
"ViT-L-14-336__openai",
32+
"ViT-L-14-336__axera",
3233
"ViT-L-14-quickgelu__dfn2b",
3334
"ViT-L-14__laion2b-s32b-b82k",
3435
"ViT-L-14__laion400m_e31",

machine-learning/immich_ml/schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ModelFormat(StrEnum):
3636
ARMNN = "armnn"
3737
ONNX = "onnx"
3838
RKNN = "rknn"
39+
AXERA = "axmodel"
3940

4041

4142
class ModelSource(StrEnum):
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2019-2024 Axera Semiconductor Co., Ltd. All Rights Reserved.
2+
#
3+
# This source file is the property of Axera Semiconductor Co., Ltd. and
4+
# may not be copied or distributed in any isomorphic form without the prior
5+
# written consent of Axera Semiconductor Co., Ltd.
6+
#
7+
8+
# thanks to community contributors list below:
9+
# zylo117: https://github.com/zylo117, first implementation of the axclrt backend
10+
11+
from ._providers import axengine_provider_name, axclrt_provider_name
12+
from ._providers import get_all_providers, get_available_providers
13+
14+
# check if axclrt is installed, or is a supported chip(e.g. AX650, AX620E etc.)
15+
_available_providers = get_available_providers()
16+
if not _available_providers:
17+
raise ImportError(
18+
f"No providers found. Please make sure you have installed one of the following: {get_all_providers()}")
19+
print("[INFO] Available providers: ", _available_providers)
20+
21+
from ._node import NodeArg
22+
from ._session import SessionOptions, InferenceSession

0 commit comments

Comments
 (0)