Merge: master at 0.13.6, with the drag-ghost file and the shared model lookup ported into the split modules
This commit is contained in:
@@ -227,6 +227,15 @@ pub fn inference_cache_dir() -> PathBuf {
|
||||
data_root().join("inference")
|
||||
}
|
||||
|
||||
/// Somewhere to put a file that only needs to exist for a moment.
|
||||
///
|
||||
/// Under the data root rather than `std::env::temp_dir()`, which on Android
|
||||
/// names a directory the app cannot write to. Nothing here survives a
|
||||
/// launch on purpose: whoever writes into it deletes what they wrote.
|
||||
pub fn scratch_dir() -> PathBuf {
|
||||
data_root().join("scratch")
|
||||
}
|
||||
|
||||
/// The detector and embedder files, if both are present — and the eye
|
||||
/// models beside them, if those are.
|
||||
///
|
||||
@@ -341,6 +350,18 @@ pub(super) fn system_face_models_dirs() -> Vec<PathBuf> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The file `name` in the shared user models directory, else in the first
|
||||
/// system directory that has it — the search every account-independent
|
||||
/// model lookup makes, and the one the inference engine is told about, so
|
||||
/// that a package's models under `/usr/share` are probed and compiled for
|
||||
/// exactly as a user's own would be.
|
||||
pub fn shared_model(name: &str) -> Option<PathBuf> {
|
||||
std::iter::once(shared_face_models_dir())
|
||||
.chain(system_face_models_dirs())
|
||||
.map(|d| d.join(name))
|
||||
.find(|p| p.is_file())
|
||||
}
|
||||
|
||||
/// TRACES: FR-MRG-4
|
||||
/// The panorama border filler, as shipped in `models/inpaint/`.
|
||||
pub const INPAINT_MODEL: &str = "migan-512.onnx";
|
||||
@@ -351,10 +372,7 @@ pub const INPAINT_MODEL: &str = "migan-512.onnx";
|
||||
/// the per-account step, because a fill is not identity-bearing and no
|
||||
/// library has a reason to pin its own.
|
||||
pub fn inpaint_model() -> Option<PathBuf> {
|
||||
std::iter::once(shared_face_models_dir())
|
||||
.chain(system_face_models_dirs())
|
||||
.map(|d| d.join(INPAINT_MODEL))
|
||||
.find(|p| p.is_file())
|
||||
shared_model(INPAINT_MODEL)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user