feat: Update dependencies and implement face detection features
- Updated async-nats dependency to version 0.45.0 in both libertas_api and libertas_worker. - Introduced AI-related structures and traits in libertas_core for face detection. - Added AiConfig and FaceDetectorRuntime enums to support different face detection methods. - Implemented TractFaceDetector and RemoteNatsFaceDetector in libertas_infra for local and remote face detection. - Created FaceDetectionPlugin to integrate face detection into the media processing pipeline. - Enhanced XMP writing functionality to include face region data. - Updated PluginManager to initialize face detection plugins based on configuration.
This commit is contained in:
17
libertas_core/src/ai.rs
Normal file
17
libertas_core/src/ai.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use async_trait::async_trait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::CoreResult;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BoundingBox {
|
||||
pub x_min: f32,
|
||||
pub y_min: f32,
|
||||
pub x_max: f32,
|
||||
pub y_max: f32,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FaceDetector: Send + Sync {
|
||||
async fn detect_faces(&self, image_bytes: &[u8]) -> CoreResult<Vec<BoundingBox>>;
|
||||
}
|
||||
@@ -31,6 +31,20 @@ pub struct ThumbnailConfig {
|
||||
pub library_path: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum FaceDetectorRuntime {
|
||||
Tract,
|
||||
Onnx,
|
||||
RemoteNats { subject: String },
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
pub struct AiConfig {
|
||||
pub face_detector_runtime: FaceDetectorRuntime,
|
||||
pub face_detector_model_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone, Debug)]
|
||||
pub struct Config {
|
||||
pub database_url: String,
|
||||
@@ -50,6 +64,7 @@ pub struct Config {
|
||||
pub allowed_sort_columns: Vec<String>,
|
||||
|
||||
pub thumbnail_config: Option<ThumbnailConfig>,
|
||||
pub ai_config: Option<AiConfig>,
|
||||
}
|
||||
|
||||
fn default_max_upload_size() -> u32 {
|
||||
@@ -73,6 +88,7 @@ pub struct AppConfig {
|
||||
pub default_storage_quota_gb: Option<u64>,
|
||||
pub allowed_sort_columns: Option<Vec<String>>,
|
||||
pub thumbnail_config: Option<ThumbnailConfig>,
|
||||
pub ai_config: Option<AiConfig>,
|
||||
}
|
||||
|
||||
pub fn load_config() -> CoreResult<AppConfig> {
|
||||
@@ -108,5 +124,6 @@ pub fn load_config() -> CoreResult<AppConfig> {
|
||||
default_storage_quota_gb: Some(config.default_storage_quota_gb),
|
||||
allowed_sort_columns: Some(config.allowed_sort_columns),
|
||||
thumbnail_config: config.thumbnail_config,
|
||||
ai_config: config.ai_config,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
pub mod ai;
|
||||
pub mod authz;
|
||||
pub mod config;
|
||||
pub mod error;
|
||||
pub mod media_utils;
|
||||
pub mod models;
|
||||
pub mod plugins;
|
||||
pub mod repositories;
|
||||
pub mod schema;
|
||||
pub mod services;
|
||||
pub mod media_utils;
|
||||
Reference in New Issue
Block a user