first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+37 -36
View File
@@ -2,6 +2,12 @@ use std::sync::Arc;
use galaxyui::{Entity, ModelContext, SingletonEntity};
use input_classifier::{HeuristicClassifier, InputClassifier};
#[cfg(any(
feature = "nld_classifier_v1",
feature = "nld_classifier_v2",
feature = "nld_classifier_v3"
))]
use input_classifier::{OnnxClassifier, OnnxModel};
pub struct InputClassifierModel {
pub classifier: Arc<dyn InputClassifier>,
@@ -9,27 +15,42 @@ pub struct InputClassifierModel {
impl InputClassifierModel {
pub fn new(_ctx: &mut ModelContext<Self>) -> Self {
#[cfg(feature = "nld_onnx_model")]
match input_classifier::OnnxClassifier::new(input_classifier::OnnxModel::BertTiny) {
Ok(classifier) => {
log::info!("Loaded onnx classifier");
return Self {
classifier: Arc::new(classifier),
};
}
Err(e) => log::warn!("Failed to load onnx classifier: {e:#}"),
}
#[cfg(feature = "nld_fasttext_model")]
if is_nld_classifier_enabled(_ctx) {
match input_classifier::FasttextClassifier::new() {
#[cfg(feature = "nld_classifier_v1")]
{
match OnnxClassifier::new(OnnxModel::BertTinyV1) {
Ok(classifier) => {
log::info!("Loaded fasttext classifier");
log::info!("Loaded onnx classifier bert_tiny_v1.onnx");
return Self {
classifier: Arc::new(classifier),
};
}
Err(e) => log::warn!("Failed to load fasttext classifier: {e:#}"),
Err(e) => log::warn!("Failed to load onnx classifier bert_tiny_v1.onnx: {e:#}"),
}
}
#[cfg(feature = "nld_classifier_v2")]
{
match OnnxClassifier::new(OnnxModel::BertTinyV2) {
Ok(classifier) => {
log::info!("Loaded onnx classifier bert_tiny_v2.onnx");
return Self {
classifier: Arc::new(classifier),
};
}
Err(e) => log::warn!("Failed to load onnx classifier bert_tiny_v2.onnx: {e:#}"),
}
}
#[cfg(feature = "nld_classifier_v3")]
{
match OnnxClassifier::new(OnnxModel::BertTinyV3) {
Ok(classifier) => {
log::info!("Loaded onnx classifier bert_tiny_v3.onnx");
return Self {
classifier: Arc::new(classifier),
};
}
Err(e) => log::warn!("Failed to load onnx classifier bert_tiny_v3.onnx: {e:#}"),
}
}
@@ -48,23 +69,3 @@ impl Entity for InputClassifierModel {
}
impl SingletonEntity for InputClassifierModel {}
#[cfg(feature = "nld_fasttext_model")]
/// Returns true iff the NLD classifier model is enabled.
pub fn is_nld_classifier_enabled(ctx: &galaxyui::AppContext) -> bool {
use galaxy_core::user_preferences::GetUserPreferences as _;
use galaxy_core::{channel::ChannelState, features::FeatureFlag};
if ChannelState::channel().is_dogfood() {
// The `EnableNLDClassifierModel` can be used to force enable / disable
// use if it is set.
ctx.private_user_preferences()
.read_value("EnableNLDClassifierModel")
.ok()
.flatten()
.and_then(|s| s.parse().ok())
.unwrap_or(FeatureFlag::NLDClassifierModelEnabled.is_enabled())
} else {
FeatureFlag::NLDClassifierModelEnabled.is_enabled()
}
}