Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

FP1b: an axis judges only what a file has. A script scored with raea's own taxonomy came back blurry, glowing and frozen, because picture heads scored its empty picture columns; now each axis needs rows of its own modality, and a script's windows say nothing until an axis reads text (tested)

shinyobjectz6c106fb8f48d
diff --git a/systems/columns/src/window.rs b/systems/columns/src/window.rs
index f7a13357..c19dcb58 100644
--- a/systems/columns/src/window.rs
+++ b/systems/columns/src/window.rs
@@ -46,6 +46,17 @@ impl Modality {
Modality::Text => "text",
}
}
+ /// Whether a file's columns have rows this modality reads: a script has no picture, a video no text
+ pub fn in_file(self, c: &Columns) -> bool {
+ !match self {
+ Modality::Picture | Modality::Change => &c.sig,
+ Modality::Look => &c.look,
+ Modality::Sound => &c.clap,
+ Modality::Events => &c.yam,
+ Modality::Text => &c.text,
+ }
+ .is_empty()
+ }
}
fn rows(v: &[f32], dim: usize, a: usize, b: usize) -> &[f32] {
diff --git a/systems/fingerprint-use/src/score.rs b/systems/fingerprint-use/src/score.rs
index 75f76b41..44e3f2ca 100644
--- a/systems/fingerprint-use/src/score.rs
+++ b/systems/fingerprint-use/src/score.rs
@@ -110,9 +110,10 @@ pub fn score(fp: &Fingerprint, words: Option<&Words>, trained: Option<&Trained>,
loop {
let b = (a + WIN).min(c.dur.max(0.25));
let row = features(c, a, b);
- let nearest = |m: Modality| words.and_then(|w| w.nearest(&row, m));
+ let nearest = |m: Modality| words.filter(|_| m.in_file(c)).and_then(|w| w.nearest(&row, m));
let head = |name: &str| trained.and_then(|t| t.heads.iter().find(|h| h.axis == name));
- let axes: Vec<AxisScore> = fp.axes.iter().filter_map(|ax| one(head(&ax.name), words, &ax.name, ax.modality, &row)).collect();
+ // an axis judges only what the file has: a script's windows hold no picture to call blurry
+ let axes: Vec<AxisScore> = fp.axes.iter().filter(|ax| ax.modality.in_file(c)).filter_map(|ax| one(head(&ax.name), words, &ax.name, ax.modality, &row)).collect();
let (l0, l1) = ((a * 10.0) as usize, ((b * 10.0) as usize).max((a * 10.0) as usize + 1));
let lv = c.level.get(l0.min(c.level.len())..l1.min(c.level.len())).unwrap_or(&[]);
let level = if lv.is_empty() { -100.0 } else { lv.iter().sum::<f32>() / lv.len() as f32 };
diff --git a/systems/fingerprint-use/src/tests.rs b/systems/fingerprint-use/src/tests.rs
index b99c1ee8..eb2cba88 100644
--- a/systems/fingerprint-use/src/tests.rs
+++ b/systems/fingerprint-use/src/tests.rs
@@ -107,3 +107,18 @@ fn a_profile_critiques_a_piece() {
assert_eq!(out.len(), 1);
assert_eq!((out[0].measure.as_str(), out[0].move_.as_str(), out[0].at), ("brightness", "raise", Some((4.0, 8.0))));
}
+
+/// A script has no picture: score judges it on text axes only, never calls its windows blurry, and a video's picture
+/// axes still score
+#[test]
+fn an_axis_judges_only_what_the_file_has() {
+ use raea_sys_columns::{CLAP, Columns, SIG, TEXT, window::Modality};
+ let fp = base("t");
+ let w = Words { axes: vec![("blur".into(), Modality::Picture, vec![0.3; SIG])], sound_vocab: vec![vec![0.1; CLAP]; 2], picture_vocab: vec![vec![0.2; SIG], vec![-0.2; SIG]], text_vocab: vec![], made_from: vec![] };
+ let script = Columns { dur: 3.0, text: vec![0.1; TEXT * 2], ..Default::default() };
+ let s = crate::score::score(&fp, Some(&w), None, &script, "script.md");
+ assert!(!s.windows.is_empty() && s.windows.iter().all(|x| x.axes.is_empty() && x.seen.is_none()), "{:?}", s.windows.iter().map(|x| x.axes.iter().map(|a| a.axis.clone()).collect::<Vec<_>>()).collect::<Vec<_>>());
+ let video = Columns { dur: 3.0, sig: vec![0.1; SIG * 24], ..Default::default() };
+ let v = crate::score::score(&fp, Some(&w), None, &video, "cut.mp4");
+ assert!(v.windows.iter().all(|x| x.axes.iter().any(|a| a.axis == "blur")));
+}