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 graph = witx::load_by_name( 7 "mobilenet", 8 witx::GraphEncoding::Onnx, 9 witx::ExecutionTarget::CPU, 10 )?; 11 let tensor = fs::read("fixture/tensor.bgr") 12 .context("the tensor file to be mapped to the fixture directory")?; 13 let results = witx::classify(graph, tensor)?; 14 let top_five = &sort_results(&results)[..5]; 15 println!("found results, sorted top 5: {top_five:?}"); 16 assert_eq!(top_five[0].class_id(), 284); 17 Ok(()) 18 } 19