feat: real service test endpoints (proxy 7-route round-trip, core/chat/vlm/markbase/embedding), unified log paths + errorLog, pipeline tools/import/export/folder APIs, face pipeline check, dynamic concurrency tuning
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled

This commit is contained in:
Accusys
2026-11-16 18:16:46 +08:00
parent d21d1ab960
commit 083d73d287
88 changed files with 12216 additions and 1096 deletions
+13 -6
View File
@@ -12,20 +12,28 @@ MODEL = None
TOKENIZER = None
DEVICE = None
def load_model(model_path: str = "google/embeddinggemma-300m"):
def load_model(model_path: str = ""):
global MODEL, TOKENIZER, DEVICE
if MODEL is not None:
return
import os
# 一律使用本地模型目錄,絕不上網
local = os.path.expanduser("~/momentry/models/embeddinggemma-300m")
if not (os.path.isdir(local) and os.path.isfile(os.path.join(local, "config.json"))):
raise RuntimeError(
f"[EmbeddingGemma] Local model not found at {local}. "
"Please copy the model files (config.json, model.safetensors, tokenizer*) to this directory."
)
DEVICE = "mps" if torch.backends.mps.is_available() else "cpu"
dtype = torch.float32
print(f"[EmbeddingGemma] Loading model on {DEVICE} (dtype={dtype})...")
print(f"[EmbeddingGemma] Loading model from local: {local} on {DEVICE} (dtype={dtype})...")
t0 = time.time()
MODEL = AutoModel.from_pretrained(
model_path,
local,
torch_dtype=dtype,
trust_remote_code=True,
).eval().to(DEVICE)
TOKENIZER = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
TOKENIZER = AutoTokenizer.from_pretrained(local, trust_remote_code=True)
print(f"[EmbeddingGemma] Loaded in {time.time()-t0:.1f}s on {DEVICE}")
def embed(texts: list[str]) -> list[list[float]]:
@@ -79,7 +87,6 @@ def health():
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=11436)
parser.add_argument("--model", type=str, default="google/embeddinggemma-300m")
args = parser.parse_args()
load_model(args.model)
load_model() # 一律使用 ~/momentry/models/embeddinggemma-300m,絕不上網
app.run(host="0.0.0.0", port=args.port, threaded=True)