fix: upgrade ONNX Runtime to 1.18.0 for IR v10, mark Detection models as optional
Build and Deploy / build (push) Successful in 2m43s
Build and Deploy / deploy (push) Has been skipped

This commit is contained in:
2026-07-16 23:49:03 +00:00
parent 1ff489971b
commit eb995760f7
2 changed files with 25 additions and 18 deletions
+5 -5
View File
@@ -11,11 +11,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
&& rm -rf /var/lib/apt/lists/*
# 安装 ONNX Runtime
RUN wget -q https://github.com/microsoft/onnxruntime/releases/download/v1.16.3/onnxruntime-linux-x64-1.16.3.tgz \
&& tar -xzf onnxruntime-linux-x64-1.16.3.tgz \
&& mv onnxruntime-linux-x64-1.16.3 /usr/local/onnxruntime \
&& rm onnxruntime-linux-x64-1.16.3.tgz
# 安装 ONNX Runtime 1.18.0 (支持 IR version 10)
RUN wget -q https://github.com/microsoft/onnxruntime/releases/download/v1.18.0/onnxruntime-linux-x64-1.18.0.tgz \
&& tar -xzf onnxruntime-linux-x64-1.18.0.tgz \
&& mv onnxruntime-linux-x64-1.18.0 /usr/local/onnxruntime \
&& rm onnxruntime-linux-x64-1.18.0.tgz
ENV ONNXRUNTIME_DIR=/usr/local/onnxruntime
ENV PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
+20 -13
View File
@@ -25,15 +25,18 @@ type Handler struct {
mu sync.RWMutex
}
// 模型配置:本地文件名 -> 远程文件名
var modelConfigs = map[string]string{
"CRNN_Math.onnx": "[AntiCAP]-CRNN_Math.onnx",
"OCR.onnx": "[Dddd]-OCR.onnx",
"Rotation-RotNetR.onnx": "[AntiCAP]-Rotation-RotNetR.onnx",
"Siamese-ResNet18.onnx": "[AntiCAP]-Siamese-ResNet18.onnx",
"CharSets.txt": "[Dddd]-CharSets.txt",
"Detection_Icon.onnx": "Detection_Icon.onnx",
"Detection_Text.onnx": "Detection_Text.onnx",
// 模型配置:本地文件名 -> 远程文件名(可选模型用 optional 标记)
var modelConfigs = map[string]struct {
remote string
optional bool
}{
"CRNN_Math.onnx": {remote: "[AntiCAP]-CRNN_Math.onnx", optional: false},
"OCR.onnx": {remote: "[Dddd]-OCR.onnx", optional: false},
"Rotation-RotNetR.onnx": {remote: "[AntiCAP]-Rotation-RotNetR.onnx", optional: false},
"Siamese-ResNet18.onnx": {remote: "[AntiCAP]-Siamese-ResNet18.onnx", optional: false},
"CharSets.txt": {remote: "[Dddd]-CharSets.txt", optional: false},
"Detection_Icon.onnx": {remote: "Detection_Icon.onnx", optional: true},
"Detection_Text.onnx": {remote: "Detection_Text.onnx", optional: true},
}
// 从 Gitea 仓库下载(公开仓库,无需认证)
@@ -119,12 +122,16 @@ func (h *Handler) ensureModels() {
return
}
for localName, remoteName := range modelConfigs {
for localName, cfg := range modelConfigs {
localPath := filepath.Join(h.modelPath, localName)
if _, err := os.Stat(localPath); os.IsNotExist(err) {
fmt.Printf("下载模型: %s -> %s\n", remoteName, localName)
if err := h.downloadModel(remoteName, localPath); err != nil {
fmt.Printf("警告: 下载模型 %s 失败: %v\n", remoteName, err)
fmt.Printf("下载模型: %s -> %s\n", cfg.remote, localName)
if err := h.downloadModel(cfg.remote, localPath); err != nil {
if cfg.optional {
fmt.Printf("提示: 可选模型 %s 下载失败,相关功能不可用: %v\n", localName, err)
} else {
fmt.Printf("警告: 下载模型 %s 失败: %v\n", cfg.remote, err)
}
} else {
fmt.Printf("模型下载完成: %s\n", localName)
}