Files
spacedrive/core/src/node/platform.rs
Ericson "Fogo" Soares 7c90bcb95b [ENG-1479] AI Prototype (#1845)
* 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>
2023-12-19 09:28:57 +00:00

57 lines
1010 B
Rust

use crate::NodeError;
use serde::{Deserialize, Serialize};
use specta::Type;
#[allow(clippy::upper_case_acronyms)]
#[repr(u8)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type, Eq, PartialEq)]
pub enum Platform {
Unknown = 0,
Windows = 1,
MacOS = 2,
Linux = 3,
IOS = 4,
Android = 5,
}
impl Platform {
#[allow(unreachable_code)]
pub fn current() -> Self {
#[cfg(target_os = "windows")]
return Self::Windows;
#[cfg(target_os = "macos")]
return Self::MacOS;
#[cfg(target_os = "linux")]
return Self::Linux;
#[cfg(target_os = "ios")]
return Self::IOS;
#[cfg(target_os = "android")]
return Self::Android;
Self::Unknown
}
}
impl TryFrom<u8> for Platform {
type Error = NodeError;
fn try_from(value: u8) -> Result<Self, Self::Error> {
let s = match value {
0 => Self::Unknown,
1 => Self::Windows,
2 => Self::MacOS,
3 => Self::Linux,
4 => Self::IOS,
5 => Self::Android,
_ => return Err(NodeError::InvalidPlatformInt(value)),
};
Ok(s)
}
}