1 use anyhow::{Context, Result};
2 use std::fs;
3 use test_programs::nn::{sort_results, wit};
4
main() -> Result<()>5 pub fn main() -> Result<()> {
6 let model = fs::read("fixture/model.onnx")
7 .context("the model file to be mapped to the fixture directory")?;
8 let graph = wit::load(
9 &[model],
10 wit::GraphEncoding::Onnx,
11 wit::ExecutionTarget::Cpu,
12 )?;
13 let tensor = fs::read("fixture/000000062808.rgb")
14 .context("the tensor file to be mapped to the fixture directory")?;
15 let results = wit::classify(graph, ("input", tensor))?;
16 let top_five = &sort_results(&results)[..5];
17 // 963 is "meat loaf, meatloaf."
18 // https://github.com/onnx/models/blob/bec48b6a70e5e9042c0badbaafefe4454e072d08/validated/vision/classification/synset.txt#L963
19 assert_eq!(top_five[0].class_id(), 963);
20 println!("found results, sorted top 5: {top_five:?}");
21 Ok(())
22 }
23