diff --git a/Cargo.toml b/Cargo.toml index d1fc72b..fd34eed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,11 +62,12 @@ features = [ "bevy_winit", "multi-threaded", "png", + "tonemapping_luts", ] [dependencies.ort] -version = "2.0.0-rc.0" +version = "2.0.0-rc.2" default-features = false features = [ "cuda", diff --git a/benches/modnet.rs b/benches/modnet.rs index 853f23b..d5473c4 100644 --- a/benches/modnet.rs +++ b/benches/modnet.rs @@ -86,7 +86,7 @@ fn modnet_output_to_luma_images_benchmark(c: &mut Criterion) { let session = Session::builder().unwrap() .with_optimization_level(GraphOptimizationLevel::Level3).unwrap() - .with_model_from_file("assets/modnet_photographic_portrait_matting.onnx").unwrap(); + .commit_from_file("assets/modnet_photographic_portrait_matting.onnx").unwrap(); let data = vec![0u8; (1920 * 1080 * 4) as usize]; let image: Image = Image::new( @@ -123,7 +123,7 @@ fn modnet_inference_benchmark(c: &mut Criterion) { let session = Session::builder().unwrap() .with_optimization_level(GraphOptimizationLevel::Level3).unwrap() - .with_model_from_file("assets/modnet_photographic_portrait_matting.onnx").unwrap(); + .commit_from_file("assets/modnet_photographic_portrait_matting.onnx").unwrap(); MAX_RESOLUTIONS.iter().for_each(|(width, height)| { let data = vec![0u8; *width as usize * *height as usize * 4]; diff --git a/benches/yolo_v8.rs b/benches/yolo_v8.rs index 6e0439f..1d7ed29 100644 --- a/benches/yolo_v8.rs +++ b/benches/yolo_v8.rs @@ -80,7 +80,7 @@ fn process_output_benchmark(c: &mut Criterion) { let session = Session::builder().unwrap() .with_optimization_level(GraphOptimizationLevel::Level3).unwrap() - .with_model_from_file("assets/yolov8n.onnx").unwrap(); + .commit_from_file("assets/yolov8n.onnx").unwrap(); RESOLUTIONS.iter() .for_each(|(width, height)| { @@ -117,7 +117,7 @@ fn inference_benchmark(c: &mut Criterion) { let session = Session::builder().unwrap() .with_optimization_level(GraphOptimizationLevel::Level3).unwrap() - .with_model_from_file("assets/yolov8n.onnx").unwrap(); + .commit_from_file("assets/yolov8n.onnx").unwrap(); RESOLUTIONS.iter().for_each(|(width, height)| { let data = vec![0u8; *width as usize * *height as usize * 4]; diff --git a/src/lib.rs b/src/lib.rs index 62038ed..d8a19a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ impl AssetLoader for OnnxLoader { // TODO: add session configuration let session = Session::builder()? .with_optimization_level(GraphOptimizationLevel::Level3)? - .with_model_from_memory(&bytes)?; + .commit_from_memory(&bytes)?; Ok(Onnx { session: Arc::new(Mutex::new(Some(session))), diff --git a/src/models/flame.rs b/src/models/flame.rs index fd24508..6da6e92 100644 --- a/src/models/flame.rs +++ b/src/models/flame.rs @@ -134,10 +134,10 @@ pub fn post_process( vertices: &ort::Value, landmarks: &ort::Value, ) -> FlameOutput { - let vertices_tensor = vertices.extract_tensor::().unwrap(); + let vertices_tensor = vertices.try_extract_tensor::().unwrap(); let vertices_view = vertices_tensor.view(); // [8, 5023, 3] - let landmarks_tensor = landmarks.extract_tensor::().unwrap(); + let landmarks_tensor = landmarks.try_extract_tensor::().unwrap(); let landmarks_view = landmarks_tensor.view(); // [8, 68, 3] let vertices = vertices_view.outer_iter() diff --git a/src/models/lightglue.rs b/src/models/lightglue.rs index 911bc12..6937f83 100644 --- a/src/models/lightglue.rs +++ b/src/models/lightglue.rs @@ -100,13 +100,13 @@ pub fn post_process( kpts1: &ort::Value, matches: &ort::Value, ) -> Result, &'static str> { - let kpts0_tensor = kpts0.extract_tensor::().unwrap(); + let kpts0_tensor = kpts0.try_extract_tensor::().unwrap(); let kpts0_view = kpts0_tensor.view(); - let kpts1_tensor = kpts1.extract_tensor::().unwrap(); + let kpts1_tensor = kpts1.try_extract_tensor::().unwrap(); let kpts1_view = kpts1_tensor.view(); - let matches = matches.extract_tensor::().unwrap(); + let matches = matches.try_extract_tensor::().unwrap(); let matches_view = matches.view(); Ok( diff --git a/src/models/modnet.rs b/src/models/modnet.rs index d26b0ac..0f1daa6 100644 --- a/src/models/modnet.rs +++ b/src/models/modnet.rs @@ -52,7 +52,7 @@ pub fn modnet_inference( pub fn modnet_output_to_luma_images( output_value: &ort::Value, ) -> Vec { - let tensor = output_value.extract_tensor::().unwrap(); + let tensor = output_value.try_extract_tensor::().unwrap(); let data = tensor.view(); let shape = data.shape(); diff --git a/src/models/yolo_v8.rs b/src/models/yolo_v8.rs index eb24863..0c28fed 100644 --- a/src/models/yolo_v8.rs +++ b/src/models/yolo_v8.rs @@ -90,7 +90,7 @@ pub fn process_output( ) -> Vec { let mut boxes = Vec::new(); - let tensor = output.extract_tensor::().unwrap(); + let tensor = output.try_extract_tensor::().unwrap(); let data = tensor.view().t().into_owned(); for detection in data.axis_iter(Axis(0)) {