Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions crates/facelock-cli/src/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct ModelEntry {
#[serde(default)]
url: String,
#[serde(default)]
#[allow(dead_code)] // parsed from manifest TOML; used in tests
optional: bool,
}

Expand Down Expand Up @@ -505,12 +506,13 @@ fn wizard_model_download(theme: &ColorfulTheme, config: &Config) -> anyhow::Resu
let configured_detector = &config.recognition.detector_model;
let configured_embedder = &config.recognition.embedder_model;

// Only download the models actually selected in the config.
// Non-optional (default) models that aren't selected are skipped — the user
// chose different models, so there is no point fetching the defaults too.
let needed: Vec<&ModelEntry> = manifest
.models
.iter()
.filter(|m| {
!m.optional || m.filename == *configured_detector || m.filename == *configured_embedder
})
.filter(|m| m.filename == *configured_detector || m.filename == *configured_embedder)
.collect();
Comment on lines +509 to 516

// Check which models actually need downloading
Expand Down Expand Up @@ -1003,18 +1005,18 @@ fn run_non_interactive() -> anyhow::Result<()> {

let model_dir = Path::new(&config.daemon.model_dir);

// 3. Check and download needed models:
// - All non-optional models (defaults)
// - Any model whose filename matches the current config (user switched to optional models)
// 3. Check and download only the models actually selected in the config.
// Non-optional (default) models that aren't referenced by the config are
// skipped — if the user chose different models there is no reason to fetch
// the defaults as well. On a first run the config defaults resolve to the
// standard models (scrfd_2.5g + w600k_r50) so those are still downloaded.
let configured_detector = &config.recognition.detector_model;
let configured_embedder = &config.recognition.embedder_model;

let needed: Vec<&ModelEntry> = manifest
.models
.iter()
.filter(|m| {
!m.optional || m.filename == *configured_detector || m.filename == *configured_embedder
})
.filter(|m| m.filename == *configured_detector || m.filename == *configured_embedder)
.collect();
Comment on lines 1013 to 1020

println!("Checking {} model(s)...\n", needed.len());
Expand Down
Loading