1 use anyhow::{Context, Result}; 2 use std::fs; 3 use test_programs::nn::{sort_results, witx}; 4 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 = witx::load( 9 &[&model], 10 witx::GraphEncoding::Onnx, 11 witx::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 = witx::classify(graph, 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