From c0fa9d0700af2691573d0e03a2b049d473417624 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 8 May 2026 10:35:38 +0800 Subject: [PATCH] feat: auto-rebuild face gallery after import/add/delete --- internal/web/ui.go | 16 ++++++++++++++++ internal/web/ui/templates/face_gallery.html | 3 --- .../__pycache__/__init__.cpython-311.pyc | Bin 618 -> 627 bytes .../__pycache__/aggregate.cpython-311.pyc | Bin 1456 -> 1465 bytes .../__pycache__/align.cpython-311.pyc | Bin 2323 -> 2332 bytes .../__pycache__/dataset.cpython-311.pyc | Bin 3977 -> 3986 bytes .../__pycache__/db.cpython-311.pyc | Bin 7138 -> 7182 bytes .../__pycache__/detector.cpython-311.pyc | Bin 36311 -> 36320 bytes .../__pycache__/recognizer.cpython-311.pyc | Bin 3721 -> 3730 bytes .../__pycache__/report.cpython-311.pyc | Bin 4133 -> 4142 bytes .../__pycache__/types.cpython-311.pyc | Bin 4234 -> 4243 bytes 11 files changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/web/ui.go b/internal/web/ui.go index c5f3c0c..b584158 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -3964,6 +3964,7 @@ func (u *UI) actionFaceGalleryAdd(w http.ResponseWriter, r *http.Request) { return } defer f.Close() + u.rebuildFaceGallery() io.Copy(f, file) http.Redirect(w, r, "/ui/face-gallery?msg=ok", http.StatusFound) } @@ -4023,6 +4024,7 @@ func (u *UI) actionFaceGalleryDelete(w http.ResponseWriter, r *http.Request) { http.Error(w, "invalid", http.StatusBadRequest) return } + u.rebuildFaceGallery() repo := storage.NewFaceGalleryRepo(filepath.Join("resources", "standard_resources", "face_gallery", "face_gallery.db")) repo.DeletePerson(id) http.Redirect(w, r, "/ui/face-gallery", http.StatusFound) @@ -4082,8 +4084,22 @@ func (u *UI) actionFaceGalleryImport(w http.ResponseWriter, r *http.Request) { io.Copy(f, file) f.Close() file.Close() + u.rebuildFaceGallery() count++ } } http.Redirect(w, r, fmt.Sprintf("/ui/face-gallery?msg=已导入 %d 张照片", count), http.StatusFound) } + +func (u *UI) rebuildFaceGallery() { + builder := &service.FaceGalleryBuilder{ + PythonExe: "python", + BuildScript: filepath.Join("tools", "build_gallery.py"), + DetModel: filepath.Join("tools", "models", "RetinaFace_mobile320.onnx"), + RecogModel: filepath.Join("tools", "models", "mobilefacenet_arcface_prenorm.onnx"), + DetOutputsConfig: filepath.Join("tools", "models", "retinaface_mobile320_config.json"), + DatasetDir: filepath.Join("dataset"), + OutputDB: filepath.Join("resources", "standard_resources", "face_gallery", "face_gallery.db"), + } + builder.Build() +} diff --git a/internal/web/ui/templates/face_gallery.html b/internal/web/ui/templates/face_gallery.html index 9636bb0..6828a1b 100644 --- a/internal/web/ui/templates/face_gallery.html +++ b/internal/web/ui/templates/face_gallery.html @@ -47,9 +47,6 @@