fix: upgrade ONNX Runtime to 1.18.0 for IR v10, mark Detection models as optional
This commit is contained in:
+20
-13
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user