mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-06 22:33:34 -04:00
* First draft on image labeling * Fixing execution providers for other OSs * Better error handling and shutdown * Working with shallow media processor * bruh * Fix warnings * Now hooked to media processor job * Link desktop app with libonnxruntime to avoid TLS error during startup * Be able to change models on runtime Revert to use labels table instead of tags * A bug on a model-less inference * Show AI labels on Inspector - Change yolo inference to use half precision - Add labels api to core * Remove LD_PRELOAD * Fix race condition on model executor shutdown * Don't load all images in memory moron * Embeed yolo model in prod build - Change yolo model path to new one relative to executable * Disable volume watcher on linux, it was crashing the app - Invalidate labels when they are updated * Rust fmt * Minor changes * Gate onnxruntime linking to the ai-models feature * Add build script to sd-server to handle onnxruntime linking workaround * Move AI stuff to its own crate and normalize deps * Rust fmt * Don't regenerate labels unless asked to * Now blazingly fast * Bad merge * Fix * Fix * Add backend logic to download extra yolo models * Add models api route - Add api call to get available model version - Add api call to change the model version * Improve new model download logic - Add frontend to change image labeler model * Fix new model downloader * Fix model select width * invalidate labels count after media_processor generates a new output * Rename AI crate and first draft on download notifications * fix types --------- Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Co-authored-by: Brendan Allan <brendonovich@outlook.com>
126 lines
2.8 KiB
Rust
126 lines
2.8 KiB
Rust
use sd_prisma::prisma;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use specta::Type;
|
|
|
|
#[derive(Serialize, Deserialize, Type, Debug, Clone)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum Range<T> {
|
|
From(T),
|
|
To(T),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Type, Debug, Clone, Copy)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub enum SortOrder {
|
|
Asc,
|
|
Desc,
|
|
}
|
|
|
|
impl From<SortOrder> for prisma::SortOrder {
|
|
fn from(value: SortOrder) -> prisma::SortOrder {
|
|
match value {
|
|
SortOrder::Asc => prisma::SortOrder::Asc,
|
|
SortOrder::Desc => prisma::SortOrder::Desc,
|
|
}
|
|
}
|
|
}
|
|
|
|
// #[derive(Deserialize, Type, Debug, Clone)]
|
|
// #[serde(untagged)]
|
|
// pub enum MaybeNot<T> {
|
|
// None(T),
|
|
// Not { not: T },
|
|
// }
|
|
|
|
// impl<T> MaybeNot<T> {
|
|
// pub fn into_prisma<R: From<prisma_client_rust::Operator<R>>>(self, param: fn(T) -> R) -> R {
|
|
// match self {
|
|
// Self::None(v) => param(v),
|
|
// Self::Not { not } => prisma_client_rust::not![param(not)],
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
#[derive(Deserialize, Type, Debug)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct CursorOrderItem<T> {
|
|
pub order: SortOrder,
|
|
pub data: T,
|
|
}
|
|
|
|
#[derive(Deserialize, Type, Debug)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum OrderAndPagination<TId, TOrder, TCursor> {
|
|
OrderOnly(TOrder),
|
|
Offset { offset: i32, order: Option<TOrder> },
|
|
Cursor { id: TId, cursor: TCursor },
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Type, Debug, Clone)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum InOrNotIn<T> {
|
|
In(Vec<T>),
|
|
NotIn(Vec<T>),
|
|
}
|
|
|
|
impl<T> InOrNotIn<T> {
|
|
pub fn is_empty(&self) -> bool {
|
|
match self {
|
|
Self::In(v) => v.is_empty(),
|
|
Self::NotIn(v) => v.is_empty(),
|
|
}
|
|
}
|
|
|
|
pub fn into_param<TParam>(
|
|
self,
|
|
in_fn: fn(Vec<T>) -> TParam,
|
|
not_in_fn: fn(Vec<T>) -> TParam,
|
|
) -> Option<TParam> {
|
|
self.is_empty()
|
|
.then_some(None)
|
|
.unwrap_or_else(|| match self {
|
|
Self::In(v) => Some(in_fn(v)),
|
|
Self::NotIn(v) => Some(not_in_fn(v)),
|
|
})
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Type, Debug, Clone)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub enum TextMatch {
|
|
Contains(String),
|
|
StartsWith(String),
|
|
EndsWith(String),
|
|
Equals(String),
|
|
}
|
|
|
|
impl TextMatch {
|
|
pub fn is_empty(&self) -> bool {
|
|
match self {
|
|
Self::Contains(v) => v.is_empty(),
|
|
Self::StartsWith(v) => v.is_empty(),
|
|
Self::EndsWith(v) => v.is_empty(),
|
|
Self::Equals(v) => v.is_empty(),
|
|
}
|
|
}
|
|
|
|
// 3. Update the to_param method of TextMatch
|
|
pub fn into_param<TParam>(
|
|
self,
|
|
contains_fn: fn(String) -> TParam,
|
|
starts_with_fn: fn(String) -> TParam,
|
|
ends_with_fn: fn(String) -> TParam,
|
|
equals_fn: fn(String) -> TParam,
|
|
) -> Option<TParam> {
|
|
self.is_empty()
|
|
.then_some(None)
|
|
.unwrap_or_else(|| match self {
|
|
Self::Contains(v) => Some(contains_fn(v)),
|
|
Self::StartsWith(v) => Some(starts_with_fn(v)),
|
|
Self::EndsWith(v) => Some(ends_with_fn(v)),
|
|
Self::Equals(v) => Some(equals_fn(v)),
|
|
})
|
|
}
|
|
}
|