Let the user choose which SCRFD finds their faces
faces.md §12.3 measured what the cheapest detector costs: the small faces in every group shot, and a dog embedded a dozen times. Which trade is right depends on the machine doing the sweep — a desktop left overnight and a tablet on a battery want different answers — so the detector is now a per-device setting, Fast / Balanced / Thorough on the settings page beside the indexing button, persisted with the rest of the settings file. A detector is half of a model id. Every face, marker, shard and calibration is keyed on faces.model_id precisely so that a model change is a new id and a re-index rather than a silent change under existing data, and a detector change is a model change: it decides which faces exist and where the landmarks that align them land. So each choice names its own pipeline. 500M keeps the bare "w600k_mbf" every existing library was written under, so an upgrade disturbs nothing; the others are qualified. Choosing one restarts coverage from zero under the new id, the sweep re-detects, confirmed names carry across by box overlap, and the sync shards are keyed by the same id so a peer on another setting neither adopts nor pollutes them. The library controller carries the id into the sync the same way it carries the cache budget, because the sync starts from places that have no settings in reach. All three shape-fixed exports ship — APK, Arch, Flatpak — since a tablet has no other way to obtain the one it was not installed with; the APK grows by twenty megabytes for the choice.
This commit is contained in:
@@ -113,6 +113,11 @@ pub fn spawn_sync(
|
||||
catalog_path: PathBuf,
|
||||
place_path: PathBuf,
|
||||
scratch: PathBuf,
|
||||
// TRACES: FR-CULL-8
|
||||
// Which face pipeline's shards to export and adopt. From the settings
|
||||
// page by way of the library controller, because a shard written under
|
||||
// one detector's faces must not be read back as another's.
|
||||
face_model_id: String,
|
||||
) -> std::sync::mpsc::Receiver<SyncMessage> {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
|
||||
@@ -143,6 +148,7 @@ pub fn spawn_sync(
|
||||
&catalog_path,
|
||||
&place_path,
|
||||
&scratch,
|
||||
&face_model_id,
|
||||
&tx,
|
||||
)
|
||||
.await
|
||||
@@ -160,6 +166,10 @@ pub fn spawn_sync(
|
||||
rx
|
||||
}
|
||||
|
||||
// Eight, because a sync touches eight distinct things — the same reason
|
||||
// `spawn_face_sweep` carries the allow: bundling them into a struct would name
|
||||
// nothing that exists.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn run(
|
||||
backend: &dyn RemoteBackend,
|
||||
root: &str,
|
||||
@@ -167,6 +177,7 @@ async fn run(
|
||||
catalog_path: &Path,
|
||||
place_path: &Path,
|
||||
scratch: &Path,
|
||||
face_model_id: &str,
|
||||
tx: &std::sync::mpsc::Sender<SyncMessage>,
|
||||
) -> Result<SyncReport, String> {
|
||||
let mut report = SyncReport::default();
|
||||
@@ -180,7 +191,16 @@ async fn run(
|
||||
sync_shards(backend, &base, thumbs_dir, scratch, &mut report).await?;
|
||||
|
||||
let _ = tx.send(SyncMessage::Status("checking faces…".into()));
|
||||
sync_face_shards(backend, &base, catalog_path, scratch, &mut report, tx).await?;
|
||||
sync_face_shards(
|
||||
backend,
|
||||
&base,
|
||||
catalog_path,
|
||||
scratch,
|
||||
face_model_id,
|
||||
&mut report,
|
||||
tx,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let _ = tx.send(SyncMessage::Status("checking collections…".into()));
|
||||
sync_catalog(backend, &base, catalog_path, scratch, &mut report).await?;
|
||||
@@ -361,6 +381,7 @@ async fn sync_face_shards(
|
||||
base: &RemotePath,
|
||||
catalog_path: &Path,
|
||||
scratch: &Path,
|
||||
face_model_id: &str,
|
||||
report: &mut SyncReport,
|
||||
tx: &std::sync::mpsc::Sender<SyncMessage>,
|
||||
) -> Result<(), String> {
|
||||
@@ -382,7 +403,7 @@ async fn sync_face_shards(
|
||||
};
|
||||
let client = store.client_id().to_string();
|
||||
|
||||
let model = crate::identity_ui::MODEL_ID;
|
||||
let model = face_model_id;
|
||||
|
||||
// ---- everything this device has detected, into the shards ------------
|
||||
if let Ok(catalog) = dr_catalog::Catalog::open(catalog_path) {
|
||||
|
||||
+61
-27
@@ -21,10 +21,14 @@ use crate::{AppWindow, IdentityFace, IdentityPerson};
|
||||
|
||||
/// Which model's faces the screen is looking at.
|
||||
///
|
||||
/// A constant for now because exactly one model is supported at a time; it is
|
||||
/// named rather than inlined because every query in this file is keyed on it,
|
||||
/// and a library indexed across a model change holds faces from both.
|
||||
pub const MODEL_ID: &str = "w600k_mbf";
|
||||
/// Every query in this file is keyed on it, and a library indexed across a
|
||||
/// detector change holds faces from both pipelines: the screen shows the one
|
||||
/// the settings page currently names (`FaceDetector::model_id`), read at each
|
||||
/// use rather than captured once, because the page can change it while the
|
||||
/// screen is open.
|
||||
pub fn model_id(settings: &crate::settings_ui::SettingsController) -> String {
|
||||
settings.snapshot().faces.detector.model_id().to_string()
|
||||
}
|
||||
|
||||
/// Screen state that outlives a single callback.
|
||||
#[derive(Default)]
|
||||
@@ -148,6 +152,7 @@ pub fn refresh(
|
||||
ctl: &Rc<IdentityController>,
|
||||
catalog: &Rc<RefCell<Option<Catalog>>>,
|
||||
store: Option<Rc<ThumbStore>>,
|
||||
model_id: &str,
|
||||
) {
|
||||
let borrow = catalog.borrow();
|
||||
let Some(cat) = borrow.as_ref() else {
|
||||
@@ -156,7 +161,7 @@ pub fn refresh(
|
||||
return;
|
||||
};
|
||||
|
||||
let view = match identity::load_people(cat, MODEL_ID) {
|
||||
let view = match identity::load_people(cat, model_id) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
log::warn!("identity: reading people: {e}");
|
||||
@@ -268,7 +273,7 @@ pub fn refresh(
|
||||
|
||||
window.set_identity_picked(ctl.picked.borrow().len() as i32);
|
||||
drop(borrow);
|
||||
refresh_coverage(window, catalog, store.as_deref());
|
||||
refresh_coverage(window, catalog, store.as_deref(), model_id);
|
||||
|
||||
// Last, so a portrait cannot delay anything above it.
|
||||
if let Some(store) = store {
|
||||
@@ -379,13 +384,14 @@ pub fn refresh_coverage(
|
||||
window: &AppWindow,
|
||||
catalog: &Rc<RefCell<Option<Catalog>>>,
|
||||
store: Option<&ThumbStore>,
|
||||
model_id: &str,
|
||||
) {
|
||||
let borrow = catalog.borrow();
|
||||
let (Some(cat), Some(store)) = (borrow.as_ref(), store) else {
|
||||
window.set_identity_coverage(Default::default());
|
||||
return;
|
||||
};
|
||||
match crate::faces::audit(cat, store, MODEL_ID) {
|
||||
match crate::faces::audit(cat, store, model_id) {
|
||||
Ok(a) => {
|
||||
window.set_identity_coverage(a.summary().into());
|
||||
// Complete means nothing left to index, not "every image has a
|
||||
@@ -591,8 +597,8 @@ pub fn wire<S, M, P>(
|
||||
// a rejection changes two counts — and a model patched by hand would
|
||||
// drift from the catalog in exactly the cases that matter.
|
||||
macro_rules! reload {
|
||||
($w:expr, $ctl:expr, $catalog:expr, $store:expr) => {
|
||||
refresh(&$w, &$ctl, &$catalog, $store())
|
||||
($w:expr, $ctl:expr, $catalog:expr, $store:expr, $settings:expr) => {
|
||||
refresh(&$w, &$ctl, &$catalog, $store(), &model_id(&$settings))
|
||||
};
|
||||
}
|
||||
|
||||
@@ -601,6 +607,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
let models_present = models.clone();
|
||||
window.on_identity_open(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
@@ -615,7 +622,7 @@ pub fn wire<S, M, P>(
|
||||
// A fact about the filesystem, so it is re-checked on every open
|
||||
// rather than cached: the user may have just put the models there.
|
||||
w.set_identity_model_missing(models_present().is_none());
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -642,6 +649,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_person_picked(move |id| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// Before the selection moves: a name typed into the field and never
|
||||
@@ -653,7 +661,7 @@ pub fn wire<S, M, P>(
|
||||
// The offer was about the person being navigated away from. Left
|
||||
// up, its "Merge" would fold whoever is selected *now*.
|
||||
clear_merge_offer(&w, &ctl);
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
reset_name_field(&w);
|
||||
});
|
||||
}
|
||||
@@ -663,6 +671,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_rename(move |name| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(person) = ctl.selected.get() else {
|
||||
@@ -697,7 +706,7 @@ pub fn wire<S, M, P>(
|
||||
Err(e) => log::warn!("identity: looking for a namesake: {e}"),
|
||||
}
|
||||
}
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
// `rename` trims; the field should show what was actually stored
|
||||
// rather than the spacing the user happened to type.
|
||||
reset_name_field(&w);
|
||||
@@ -714,6 +723,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_merge_accept(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let (Some(target), Some(source)) = (ctl.merge_offer.get(), ctl.selected.get()) else {
|
||||
@@ -733,7 +743,7 @@ pub fn wire<S, M, P>(
|
||||
}
|
||||
}
|
||||
clear_merge_offer(&w, &ctl);
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
reset_name_field(&w);
|
||||
});
|
||||
}
|
||||
@@ -767,6 +777,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_confirm_face(move |id| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(person) = ctl.selected.get() else {
|
||||
@@ -777,7 +788,7 @@ pub fn wire<S, M, P>(
|
||||
log::warn!("identity: confirm: {e}");
|
||||
}
|
||||
}
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -786,6 +797,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_reject_face(move |id| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(person) = ctl.selected.get() else {
|
||||
@@ -796,7 +808,7 @@ pub fn wire<S, M, P>(
|
||||
log::warn!("identity: reject: {e}");
|
||||
}
|
||||
}
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -827,6 +839,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_confirm_all(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(person) = ctl.selected.get() else {
|
||||
@@ -838,7 +851,7 @@ pub fn wire<S, M, P>(
|
||||
Err(e) => log::warn!("identity: confirm all: {e}"),
|
||||
}
|
||||
}
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -847,6 +860,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_split_picked(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(person) = ctl.selected.get() else {
|
||||
@@ -870,7 +884,7 @@ pub fn wire<S, M, P>(
|
||||
}
|
||||
}
|
||||
ctl.clear_picks();
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -893,7 +907,7 @@ pub fn wire<S, M, P>(
|
||||
w.set_identity_previewing(true);
|
||||
*ctl.preview.borrow_mut() = Some(crate::faces::spawn_grouping_preview(
|
||||
catalog_path,
|
||||
MODEL_ID.to_string(),
|
||||
model_id(&settings),
|
||||
settings.snapshot().faces,
|
||||
));
|
||||
|
||||
@@ -960,7 +974,7 @@ pub fn wire<S, M, P>(
|
||||
w.set_identity_regroup_status("regrouping…".into());
|
||||
*ctl.regroup.borrow_mut() = Some(crate::faces::spawn_recluster(
|
||||
catalog_path,
|
||||
MODEL_ID.to_string(),
|
||||
model_id(&settings_for_regroup),
|
||||
settings_for_regroup.snapshot().faces,
|
||||
));
|
||||
|
||||
@@ -972,6 +986,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl_tick = ctl.clone();
|
||||
let catalog_tick = catalog.clone();
|
||||
let store_tick = store.clone();
|
||||
let settings_tick = settings_for_regroup.clone();
|
||||
timer.start(
|
||||
slint::TimerMode::Repeated,
|
||||
Duration::from_millis(100),
|
||||
@@ -1020,7 +1035,13 @@ pub fn wire<S, M, P>(
|
||||
// makes new people; a stale cache would draw the
|
||||
// previous pass's faces beside the new groups.
|
||||
ctl_tick.covers.borrow_mut().clear();
|
||||
refresh(&w, &ctl_tick, &catalog_tick, store_tick());
|
||||
refresh(
|
||||
&w,
|
||||
&ctl_tick,
|
||||
&catalog_tick,
|
||||
store_tick(),
|
||||
&model_id(&settings_tick),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1036,6 +1057,7 @@ pub fn wire<S, M, P>(
|
||||
let models = models.clone();
|
||||
let paths = paths.clone();
|
||||
let gpu = gpu.clone();
|
||||
let settings_for_sweep = settings.clone();
|
||||
window.on_identity_index(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if ctl.sweep.borrow().is_some() {
|
||||
@@ -1066,7 +1088,7 @@ pub fn wire<S, M, P>(
|
||||
store_dir,
|
||||
detector,
|
||||
embedder,
|
||||
MODEL_ID.to_string(),
|
||||
model_id(&settings_for_sweep),
|
||||
dr_face::DetectOptions::default(),
|
||||
gpu,
|
||||
));
|
||||
@@ -1083,6 +1105,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl_tick = ctl.clone();
|
||||
let catalog_tick = catalog.clone();
|
||||
let store_tick = store.clone();
|
||||
let settings_tick = settings_for_sweep.clone();
|
||||
timer.start(
|
||||
slint::TimerMode::Repeated,
|
||||
Duration::from_millis(250),
|
||||
@@ -1165,7 +1188,13 @@ pub fn wire<S, M, P>(
|
||||
// grouped, so a sweep ending with an unchanged people
|
||||
// rail is expected. The coverage line is what shows it
|
||||
// worked, and Regroup is the next step.
|
||||
refresh(&w, &ctl_tick, &catalog_tick, store_tick());
|
||||
refresh(
|
||||
&w,
|
||||
&ctl_tick,
|
||||
&catalog_tick,
|
||||
store_tick(),
|
||||
&model_id(&settings_tick),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -1180,6 +1209,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_stop_indexing(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// Dropping the receiver *is* the cancellation: the worker's next
|
||||
@@ -1190,7 +1220,7 @@ pub fn wire<S, M, P>(
|
||||
a.finish("stopped");
|
||||
}
|
||||
w.set_identity_indexing(false);
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1198,9 +1228,10 @@ pub fn wire<S, M, P>(
|
||||
let weak = window.as_weak();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_check_coverage(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
refresh_coverage(&w, &catalog, store().as_deref());
|
||||
refresh_coverage(&w, &catalog, store().as_deref(), &model_id(&settings));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1209,6 +1240,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_ignore_person(move |id, on| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let person = PersonId(id.max(0) as u64);
|
||||
@@ -1225,7 +1257,7 @@ pub fn wire<S, M, P>(
|
||||
ctl.selected.set(None);
|
||||
ctl.clear_picks();
|
||||
}
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1234,10 +1266,11 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_toggle_show_ignored(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.show_ignored.set(!ctl.show_ignored.get());
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1246,6 +1279,7 @@ pub fn wire<S, M, P>(
|
||||
let ctl = ctl.clone();
|
||||
let catalog = catalog.clone();
|
||||
let store = store.clone();
|
||||
let settings = settings.clone();
|
||||
window.on_identity_delete_all(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if let Some(cat) = catalog.borrow().as_ref() {
|
||||
@@ -1257,7 +1291,7 @@ pub fn wire<S, M, P>(
|
||||
ctl.selected.set(None);
|
||||
ctl.clear_picks();
|
||||
ctl.covers.borrow_mut().clear();
|
||||
reload!(w, ctl, catalog, store);
|
||||
reload!(w, ctl, catalog, store, settings);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+44
-11
@@ -1358,9 +1358,10 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
||||
// and their absence is the ordinary state of a fresh install.
|
||||
{
|
||||
let lib = library.clone();
|
||||
let settings = settings.clone();
|
||||
move || {
|
||||
let conn = lib.session()?;
|
||||
library::face_models(&conn.account)
|
||||
library::face_models(&conn.account, settings.snapshot().faces.detector)
|
||||
}
|
||||
},
|
||||
// The sweep opens its own connection on its own thread, so it
|
||||
@@ -1504,6 +1505,7 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
||||
library.set_cache_budget(stored.cache.original_budget_bytes);
|
||||
library.set_keep_opened_originals(stored.cache.keep_opened_originals);
|
||||
library.set_timeline_bars(stored.library.timeline_bars);
|
||||
library.set_face_model_id(stored.faces.detector.model_id());
|
||||
}
|
||||
|
||||
// --- the export folder picker ----------------------------------------
|
||||
@@ -1648,6 +1650,16 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
// The pipeline the next sync and the next sweep run under, and
|
||||
// the two lines on the page that describe it: which detector
|
||||
// file is installed, and how much of the library that
|
||||
// pipeline has covered — which for a freshly chosen one is
|
||||
// nothing, and saying so is the point.
|
||||
lib.set_face_model_id(s.faces.detector.model_id());
|
||||
if let Some(w) = weak.upgrade() {
|
||||
refresh_face_status(&w, &lib, s.faces.detector);
|
||||
}
|
||||
|
||||
// Lowering the ceiling evicts, so the figure beside it has just
|
||||
// changed — leaving the old one would show the cache still over a
|
||||
// limit that was enforced a moment ago.
|
||||
@@ -1662,18 +1674,9 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
||||
// through here rather than being kept up to date continuously —
|
||||
// they are only ever looked at while this page is on screen.
|
||||
let lib = library.clone();
|
||||
let catalog = library.catalog();
|
||||
let ctl = settings.clone();
|
||||
move |w: &AppWindow| {
|
||||
let store = lib.session().and_then(|c| {
|
||||
dr_thumbs::ThumbStore::open(&library::thumbs_dir(&c.account)).ok()
|
||||
});
|
||||
identity_ui::refresh_coverage(w, &catalog, store.as_ref());
|
||||
w.set_identity_model_missing(
|
||||
lib.session()
|
||||
.and_then(|c| library::face_models(&c.account))
|
||||
.is_none(),
|
||||
);
|
||||
refresh_face_status(w, &lib, ctl.snapshot().faces.detector);
|
||||
// Here rather than at startup, on exactly the reasoning
|
||||
// above: the catalog this reads is opened on a worker now,
|
||||
// so a launch has nothing to describe, and the figure is
|
||||
@@ -3588,6 +3591,36 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
||||
/// the pinned figure is disk the user asked for and no ceiling will reclaim.
|
||||
/// One combined number would make the budget look wrong whenever a large
|
||||
/// collection was pinned.
|
||||
/// TRACES: FR-CULL-8
|
||||
/// The two face lines on the settings page: whether the chosen detector's file
|
||||
/// is installed, and how far the chosen pipeline has got through the library.
|
||||
///
|
||||
/// One function because they move together. A detector picked from the list
|
||||
/// changes which file has to exist *and* which `model_id` the coverage is
|
||||
/// counted under, and a page that updated one without the other would report
|
||||
/// "no model installed" over a coverage figure for a different model.
|
||||
fn refresh_face_status(
|
||||
window: &AppWindow,
|
||||
library: &Rc<library_ui::LibraryController>,
|
||||
detector: dr_types::FaceDetector,
|
||||
) {
|
||||
let store = library
|
||||
.session()
|
||||
.and_then(|c| dr_thumbs::ThumbStore::open(&library::thumbs_dir(&c.account)).ok());
|
||||
identity_ui::refresh_coverage(
|
||||
window,
|
||||
&library.catalog(),
|
||||
store.as_ref(),
|
||||
detector.model_id(),
|
||||
);
|
||||
window.set_identity_model_missing(
|
||||
library
|
||||
.session()
|
||||
.and_then(|c| library::face_models(&c.account, detector))
|
||||
.is_none(),
|
||||
);
|
||||
}
|
||||
|
||||
fn describe_cache_usage(library: &Rc<library_ui::LibraryController>) -> String {
|
||||
let Some(cache) = library.cache() else {
|
||||
return String::new();
|
||||
|
||||
@@ -4419,12 +4419,15 @@ pub fn shared_face_models_dir() -> PathBuf {
|
||||
/// 3. **The system directories.** Where a package installs them — the Arch
|
||||
/// package puts the pair in `/usr/share/darkroom/models`. Last, so anything
|
||||
/// the user placed themselves outranks what the package shipped.
|
||||
pub fn face_models(account: &Account) -> Option<(PathBuf, PathBuf)> {
|
||||
fn pair(dir: PathBuf) -> Option<(PathBuf, PathBuf)> {
|
||||
let detector = dir.join("scrfd_500m_640.onnx");
|
||||
pub fn face_models(
|
||||
account: &Account,
|
||||
detector: dr_types::FaceDetector,
|
||||
) -> Option<(PathBuf, PathBuf)> {
|
||||
let pair = |dir: PathBuf| {
|
||||
let detector = dir.join(detector.file_name());
|
||||
let embedder = dir.join("arcface_mbf_b1.onnx");
|
||||
(detector.is_file() && embedder.is_file()).then_some((detector, embedder))
|
||||
}
|
||||
};
|
||||
pair(face_models_dir(account))
|
||||
.or_else(|| pair(shared_face_models_dir()))
|
||||
.or_else(|| system_face_models_dirs().into_iter().find_map(pair))
|
||||
|
||||
@@ -391,6 +391,15 @@ pub struct LibraryController {
|
||||
/// wrong shape of question. A `Cell` because the page can change it while
|
||||
/// a library is open.
|
||||
timeline_bars: std::cell::Cell<u32>,
|
||||
/// TRACES: FR-CULL-8
|
||||
/// Which face pipeline this device indexes with, from the settings page.
|
||||
///
|
||||
/// Held here for the same reason as the two above: the derived sync runs
|
||||
/// from a sweep's completion and from the Sync button, neither of which
|
||||
/// has the settings in reach, and the shards it exports and adopts are
|
||||
/// keyed on this id. A `RefCell` of the id rather than the enum so that
|
||||
/// nothing here has to know how a detector becomes a model id.
|
||||
face_model_id: RefCell<String>,
|
||||
/// Where every worker this module starts reports what it is doing.
|
||||
///
|
||||
/// Held on the controller rather than passed to each function because the
|
||||
@@ -458,9 +467,22 @@ impl LibraryController {
|
||||
dr_types::CacheSettings::default().keep_opened_originals,
|
||||
),
|
||||
timeline_bars: std::cell::Cell::new(dr_types::LibrarySettings::default().timeline_bars),
|
||||
face_model_id: RefCell::new(dr_types::FaceDetector::default().model_id().to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
/// TRACES: FR-CULL-8
|
||||
/// Which face pipeline the next sync exports and adopts under.
|
||||
///
|
||||
/// Set on every settings edit like the bars above. A sync already running
|
||||
/// keeps the id it started with, which is right: its shards are half
|
||||
/// written under that one.
|
||||
pub fn set_face_model_id(&self, id: &str) {
|
||||
if *self.face_model_id.borrow() != id {
|
||||
*self.face_model_id.borrow_mut() = id.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
/// TRACES: FR-CAT-6
|
||||
/// How many bars the capture-time axis is cut into.
|
||||
///
|
||||
@@ -4016,6 +4038,7 @@ fn start_derived_sync(window: &AppWindow, ctl: &Rc<LibraryController>) {
|
||||
catalog_path,
|
||||
library::place_path(&conn.account),
|
||||
scratch,
|
||||
ctl.face_model_id.borrow().clone(),
|
||||
);
|
||||
|
||||
let timer = slint::Timer::default();
|
||||
|
||||
@@ -26,8 +26,8 @@ use std::rc::Rc;
|
||||
|
||||
use dr_types::settings::budget;
|
||||
use dr_types::{
|
||||
CollisionPolicy, ColourSpace, ExportFormat, ExportTarget, GroupNavigation, LibrarySettings,
|
||||
OutputSharpening, ScreenSize, Settings, SizingMode,
|
||||
CollisionPolicy, ColourSpace, ExportFormat, ExportTarget, FaceDetector, GroupNavigation,
|
||||
LibrarySettings, OutputSharpening, ScreenSize, Settings, SizingMode,
|
||||
};
|
||||
use slint::ComponentHandle;
|
||||
|
||||
@@ -186,6 +186,24 @@ pub fn render(window: &AppWindow, controller: &SettingsController) {
|
||||
);
|
||||
window.set_settings_cache_usage(controller.usage_label.borrow().clone().into());
|
||||
|
||||
// --- faces ---------------------------------------------------------
|
||||
//
|
||||
// TRACES: FR-CULL-8
|
||||
// Labelled from the enum's own order, so the chip index and
|
||||
// `FaceDetector::ALL` cannot disagree about which detector was picked.
|
||||
window.set_settings_face_detector_labels(slint::ModelRc::new(slint::VecModel::from(
|
||||
FaceDetector::ALL
|
||||
.iter()
|
||||
.map(|d| slint::SharedString::from(d.label()))
|
||||
.collect::<Vec<_>>(),
|
||||
)));
|
||||
window.set_settings_face_detector_selected(
|
||||
FaceDetector::ALL
|
||||
.iter()
|
||||
.position(|d| *d == s.faces.detector)
|
||||
.unwrap_or(0) as i32,
|
||||
);
|
||||
|
||||
// --- library -------------------------------------------------------
|
||||
//
|
||||
// Labelled here rather than in the page, so the chips cannot offer a count
|
||||
@@ -484,6 +502,28 @@ pub fn wire<F, G>(
|
||||
});
|
||||
}
|
||||
|
||||
// --- faces ---------------------------------------------------------
|
||||
//
|
||||
// TRACES: FR-CULL-8
|
||||
// Notified like a budget change, because the effect is outside this
|
||||
// page: the library controller carries the pipeline id into the next
|
||||
// sync, and the coverage line under the picker has to be re-counted
|
||||
// under the new id — which the caller's `on_budget_changed` does.
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
let notify = on_budget_changed.clone();
|
||||
window.on_settings_face_detector_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(choice) = FaceDetector::ALL.get(i as usize).copied() else {
|
||||
return;
|
||||
};
|
||||
ctl.edit(|s| s.faces.detector = choice);
|
||||
notify(&ctl.snapshot());
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
// --- export --------------------------------------------------------
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
|
||||
@@ -879,6 +879,12 @@ export component AppWindow inherits Window {
|
||||
in property <int> settings-target-selected: 0;
|
||||
in property <string> settings-error: "";
|
||||
|
||||
/// TRACES: FR-CULL-8
|
||||
/// Which face detector the indexing pass runs.
|
||||
in property <[string]> settings-face-detector-labels;
|
||||
in property <int> settings-face-detector-selected: 0;
|
||||
callback settings-face-detector-picked(int);
|
||||
|
||||
callback settings-group-nav-picked(int);
|
||||
callback settings-format-picked(int);
|
||||
callback settings-quality-changed(int);
|
||||
@@ -1350,6 +1356,9 @@ in property <bool> panel-visible: true;
|
||||
face-indexing: root.identity-indexing;
|
||||
face-coverage: root.identity-coverage;
|
||||
face-model-missing: root.identity-model-missing;
|
||||
face-detector-labels: root.settings-face-detector-labels;
|
||||
face-detector-selected: root.settings-face-detector-selected;
|
||||
face-detector-picked(i) => { root.settings-face-detector-picked(i); }
|
||||
library-open: root.library-open;
|
||||
thumbnail-library() => { root.library-thumbnail-all(); }
|
||||
index-faces() => { root.identity-index(); }
|
||||
|
||||
@@ -785,7 +785,7 @@ export component IdentityScreen inherits Rectangle {
|
||||
border-radius: Theme.radius;
|
||||
background: Theme.surface-raised;
|
||||
Text {
|
||||
text: "No face model installed — indexing is off.";
|
||||
text: "The chosen face detector is not installed — indexing is off.";
|
||||
color: Theme.warn-ink;
|
||||
font-size: Theme.text-sm;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,13 @@ export component SettingsPage inherits Rectangle {
|
||||
/// No model on disk, so the pass cannot run at all.
|
||||
in property <bool> face-model-missing: false;
|
||||
callback index-faces();
|
||||
/// TRACES: FR-CULL-8
|
||||
/// Which detector the pass finds faces with — docs/faces.md §12.3 for
|
||||
/// what each costs and finds. The choice is a model change: coverage is
|
||||
/// counted per pipeline, so picking another one starts from nothing.
|
||||
in property <[string]> face-detector-labels;
|
||||
in property <int> face-detector-selected: 0;
|
||||
callback face-detector-picked(int);
|
||||
|
||||
// --- cache ---------------------------------------------------------
|
||||
in-out property <string> original-budget;
|
||||
@@ -444,13 +451,32 @@ export component SettingsPage inherits Rectangle {
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
if root.library-open: Segmented {
|
||||
label: "Face detector";
|
||||
options: root.face-detector-labels;
|
||||
selected: root.face-detector-selected;
|
||||
enabled: !root.face-indexing;
|
||||
picked(i) => { root.face-detector-picked(i); }
|
||||
}
|
||||
|
||||
if root.library-open: Caption {
|
||||
text: "Fast misses the small faces in a group and "
|
||||
+ "mistakes the odd dog for one. Balanced "
|
||||
+ "finds a seventh more for almost the same "
|
||||
+ "time. Thorough finds the most and takes "
|
||||
+ "three times as long. Changing it indexes "
|
||||
+ "the library again; names you have "
|
||||
+ "confirmed are kept.";
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
if root.library-open && root.face-coverage != "": Caption {
|
||||
text: root.face-coverage;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
if root.library-open && root.face-model-missing: Caption {
|
||||
text: "No face model is installed, so this cannot run.";
|
||||
text: "The chosen detector is not installed, so this cannot run.";
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user