feat: auto-rebuild face gallery after import/add/delete
This commit is contained in:
parent
fe2c219db1
commit
c0fa9d0700
@ -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()
|
||||
}
|
||||
|
||||
@ -47,9 +47,6 @@
|
||||
<h3 class="title-with-icon">{{icon "profile"}}<span>人员列表</span></h3>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<form method="post" action="/ui/face-gallery/build">
|
||||
<button class="btn secondary" type="submit">重新生成人脸库</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user