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 @@

{{icon "profile"}}人员列表

-
- -
diff --git a/tools/gallery_builder/__pycache__/__init__.cpython-311.pyc b/tools/gallery_builder/__pycache__/__init__.cpython-311.pyc index 3629090a0d68194ff9f3738c00c742948c117300..25057fa53f00424c878484106b578a1af10df2fc 100644 GIT binary patch delta 69 zcmaFG@|lHuIWI340}x#F_`8w2l2OOq*(xTqIJKxaCL}c{CpR@Fv7n$h#@N)t!Z9T` XGtVh8IXg8kC8i`lKc{%|a>l~|9FQ1= delta 60 zcmey&@`{CfIWI340}zz;FWSgm$*64SY!wq)oLW>I6Ox*flbafoSWr+L$fj)VY!wq)oLW>I6Ox*flbafoSWr+LI6Ox*flbafoSWr+LKmsf!l?KJODk diff --git a/tools/gallery_builder/__pycache__/db.cpython-311.pyc b/tools/gallery_builder/__pycache__/db.cpython-311.pyc index dcd8dee2be5389b476d50b3db110b34f6a4ac497..e82b44231a70d55113c253e47b16611285a0e272 100644 GIT binary patch delta 71 zcmaE4-eI6Ox*flbafoSWr+LV{B?+;h2(} Zndg+4oSmAN5>t|&pHm#OIh?s$0suh_7+e4V delta 27 hcmeCPcx2AKoR^o20SGF69&F_HW@Z%K+|1l90RU+(2Uh?9 diff --git a/tools/gallery_builder/__pycache__/detector.cpython-311.pyc b/tools/gallery_builder/__pycache__/detector.cpython-311.pyc index 3738bf1c512f8b8239b0a6627ab20fba329d6de9..054c77600c8ecd77292a51a87d44f504b250accc 100644 GIT binary patch delta 56 zcmcaUo9V%9Chq0Dyj%=GaM9!MM(!<4jP8>UFo}v8n_5^nrsQVkIVC1%r{<-^l;r2< L6mNdS^tB5B3`-Ow delta 47 zcmaDbo9X&&Chq0Dyj%=GP}aX_Bli|2M!U%em_&IUQ&QX#lT$2+64e) CeGkb1 diff --git a/tools/gallery_builder/__pycache__/recognizer.cpython-311.pyc b/tools/gallery_builder/__pycache__/recognizer.cpython-311.pyc index b8f7b7ae80f76cb68173ff75bda57caabef774ab..6bcd5331f1d18cb98ff6fe5c32205ba689b3e6eb 100644 GIT binary patch delta 54 zcmeB_og~Y>oR^o20SGR7{N2dS%*5z9nV(5i%-Gbz!Z9T`GtVh8IXg8kC8i`lKc{%J IAyWho0D%AxTmS$7 delta 45 zcmbOv+bPSvoR^o20SLzI<_mYAFxl5cEkVX@hYDS`(8^aTq6 diff --git a/tools/gallery_builder/__pycache__/report.cpython-311.pyc b/tools/gallery_builder/__pycache__/report.cpython-311.pyc index 9dac0bb55c8a54a07e936e99aae6057794569033..041bd8b81b4ff8b2dda6d59cae39cec80c3ed8b7 100644 GIT binary patch delta 70 zcmZ3guug${IWI340}x#F_`8wYic`nc*(xTqIJKxaCL}c{CpR@Fv7n$h#@N)t!Z9T` YGtVh8IXg8kC8i`lKc{$e2IpQj021RD;{X5v delta 61 zcmZ3duvCG2IWI340}zz;FWSg$#i?xLY!wq)oLW>I6Ox*flbafoSWr+LI6Ox*flbafoSWr+LV{B?+;h2(} Yndg+4oSmAN5>t|&pHsZKjfsU100>wYD*ylh delta 61 zcmbQN*rmw5oR^o20SL