双档位训练体系(s高识别/n高性能 串行排队、按档发布)与 TFLite 硬件加速补丁

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-09-03 09:20:46 +08:00
co-authored by Claude Opus 4.7
parent bb75c69d91
commit 6f8c54c31d
23 changed files with 651 additions and 269 deletions
+32
View File
@@ -241,6 +241,38 @@ func initDatabase(ctx context.Context) {
}
g.Log().Infof(ctx, "数据库初始化完成(version=12)")
}
if version < 13 {
// v13:双档位训练 —— model_training + model_version 增 variant 列(s|n,默认 s 存量归 s 档)。
// 全新库建表自带该列;存量库 ADD COLUMNNOT NULL DEFAULT 's' 免回填)。
// PRAGMA table_info 逐列检测缺失才 ADD COLUMN
addCols := []struct{ table, col string }{
{"model_training", "variant"},
{"model_version", "variant"},
}
for _, c := range addCols {
cols, err := g.DB().GetAll(ctx, "PRAGMA table_info("+c.table+")")
if err != nil {
g.Log().Fatalf(ctx, "读取 %s 表结构失败: %+v", c.table, err)
}
exists := false
for _, col := range cols {
if gconv.String(col["name"]) == c.col {
exists = true
break
}
}
if exists {
continue
}
if _, err := g.DB().Exec(ctx, "ALTER TABLE "+c.table+" ADD COLUMN "+c.col+" TEXT NOT NULL DEFAULT 's'"); err != nil {
g.Log().Fatalf(ctx, "增加 %s.%s 列失败: %+v", c.table, c.col, err)
}
}
if _, err := g.DB().Exec(ctx, "PRAGMA user_version = 13"); err != nil {
g.Log().Fatalf(ctx, "库版本写入失败: %+v", err)
}
g.Log().Infof(ctx, "数据库初始化完成(version=13)")
}
// 死表清理:app_config 全局训练配置表已撤销(配置走 config.yml),存量库残留表启动即删
if _, err := g.DB().Exec(ctx, "DROP TABLE IF EXISTS app_config"); err != nil {
g.Log().Fatalf(ctx, "删除残留 app_config 表失败: %+v", err)