videre-api 0.44.0

Transport-agnostic facade over videre's face-labeling and image-serving operations
Documentation
use serde::Serialize;

/// Versioned model context attached to evidence captured by a Gallery action.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TeachingContext {
    pub embedding_model_id: String,
    pub active_profile_id: Option<i64>,
}

/// Durable learning work committed with a visible people mutation.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct LearningAcknowledgement {
    pub generation: u64,
    pub event_ids: Vec<i64>,
    pub message_key: String,
}

/// Learning status for the gallery background worker.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct FaceLearningStatus {
    pub generation: u64,
    pub trained_generation: u64,
    pub status: String,
    pub last_profile_id: Option<i64>,
    /// What became of the last trained candidate: `promoted` or `rejected`,
    /// or `None` before any candidate was stored. Lets a `current` status
    /// say whether the last run changed the profile in use.
    pub last_candidate: Option<String>,
    pub last_error: Option<String>,
    /// While `status` is `waiting`: the feedback training still needs, in
    /// words the People page shows as is (`dissolve 2 more wrong clusters`).
    pub feedback_needed: Option<String>,
    pub pending_questions: usize,
    /// The profile in use, if any: its id and stage (`suggestion` asks
    /// questions, `grouping` may also shape clustering).
    pub active_profile: Option<ActiveProfile>,
    /// What learning contributes right now, in one sentence for the People
    /// toolbar.
    pub summary: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct ActiveProfile {
    pub profile_id: i64,
    pub stage: String,
}

/// The stored outcome of one background training run.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct TrainedProfileSummary {
    pub profile_id: i64,
    pub model_kind: String,
    pub promoted: bool,
}

/// Result of answering one identity question: the new delivery state and, for
/// Yes and No, the durable learning work the answer committed.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct QuestionAnswerOutcome {
    pub status: String,
    pub acknowledgement: Option<LearningAcknowledgement>,
}

/// One labeled person: their confirmed faces plus a representative face id
/// (the primary, or lowest id) used as the card thumbnail.
#[derive(Serialize, Clone)]
pub struct PersonData {
    /// Identity: normalized, what URLs and actions use.
    pub label: String,
    /// What a reader sees. Falls back to `label` for a person whose row
    /// predates the people table.
    pub full_name: String,
    pub face_ids: Vec<i64>,
    pub representative_id: i64,
    pub hashes: Vec<String>,
}

/// One unassigned cluster (green section in the labeling UI).
#[derive(Serialize, Clone)]
pub struct ClusterData {
    pub cluster_id: i64,
    pub face_ids: Vec<i64>,
    pub hashes: Vec<String>,
}

/// One unclustered, unassigned face (orange section).
#[derive(Serialize, Clone)]
pub struct SingletonData {
    pub face_id: i64,
    pub hash: String,
}

/// Top-level payload for the labeling page.
///
/// `Default` is the "detection has never run" answer, which is a state rather
/// than an error. See `faces_list`.
#[derive(Serialize, Clone, Default)]
pub struct FacesData {
    pub people: Vec<PersonData>,
    pub clusters: Vec<ClusterData>,
    pub singletons: Vec<SingletonData>,
}

/// One face row on a cluster detail page.
#[derive(Serialize, Clone)]
pub struct ClusterFaceData {
    pub face_id: i64,
    pub hash: String,
    pub path: String,
}

/// Cluster detail: every face in one unassigned cluster.
#[derive(Serialize, Clone)]
pub struct ClusterDetail {
    pub cluster_id: i64,
    pub faces: Vec<ClusterFaceData>,
}

/// One face row on a person detail page. `is_primary` marks the current
/// default photo (the person's thumbnail on the labeling page).
#[derive(Serialize, Clone)]
pub struct PersonFaceData {
    pub face_id: i64,
    pub hash: String,
    pub path: String,
    pub is_primary: bool,
}

/// Person detail: every confirmed face for one person.
#[derive(Serialize, Clone)]
pub struct PersonDetail {
    /// Identity: what the URL and every face row use.
    pub label: String,
    /// What a reader sees, and what the page lets them edit.
    pub full_name: String,
    pub faces: Vec<PersonFaceData>,
}