refactor: improve onnxruntime logging

This commit is contained in:
Carson M.
2023-12-05 16:33:40 -06:00
parent 8e477536b4
commit 534a42a80c
6 changed files with 56 additions and 93 deletions

View File

@@ -1,14 +1,14 @@
use std::path::Path;
use image::{imageops::FilterType, ImageBuffer, Luma, Pixel};
use ort::{download::vision::DomainBasedImageClassification, inputs, ArrayExtensions, GraphOptimizationLevel, LoggingLevel, Session, Tensor};
use ort::{download::vision::DomainBasedImageClassification, inputs, ArrayExtensions, GraphOptimizationLevel, Session, Tensor};
use test_log::test;
#[test]
fn mnist_5() -> ort::Result<()> {
const IMAGE_TO_LOAD: &str = "mnist_5.jpg";
ort::init().with_name("integration_test").with_log_level(LoggingLevel::Warning).commit()?;
ort::init().with_name("integration_test").commit()?;
let session = Session::builder()?
.with_optimization_level(GraphOptimizationLevel::Level1)?

View File

@@ -7,14 +7,14 @@ use std::{
use image::{imageops::FilterType, ImageBuffer, Pixel, Rgb};
use ndarray::s;
use ort::{download::vision::ImageClassification, inputs, ArrayExtensions, FetchModelError, GraphOptimizationLevel, LoggingLevel, Session, Tensor};
use ort::{download::vision::ImageClassification, inputs, ArrayExtensions, FetchModelError, GraphOptimizationLevel, Session, Tensor};
use test_log::test;
#[test]
fn squeezenet_mushroom() -> ort::Result<()> {
const IMAGE_TO_LOAD: &str = "mushroom.png";
ort::init().with_name("integration_test").with_log_level(LoggingLevel::Warning).commit()?;
ort::init().with_name("integration_test").commit()?;
let session = Session::builder()?
.with_optimization_level(GraphOptimizationLevel::Level1)?

View File

@@ -2,7 +2,7 @@ use std::path::Path;
use image::RgbImage;
use ndarray::{Array, CowArray, Ix4};
use ort::{inputs, GraphOptimizationLevel, LoggingLevel, Session, Tensor};
use ort::{inputs, GraphOptimizationLevel, Session, Tensor};
use test_log::test;
fn load_input_image<P: AsRef<Path>>(name: P) -> RgbImage {
@@ -44,7 +44,7 @@ fn convert_image_to_cow_array(img: &RgbImage) -> CowArray<'_, f32, Ix4> {
fn upsample() -> ort::Result<()> {
const IMAGE_TO_LOAD: &str = "mushroom.png";
ort::init().with_name("integration_test").with_log_level(LoggingLevel::Warning).commit()?;
ort::init().with_name("integration_test").commit()?;
let session_data =
std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests").join("data").join("upsample.onnx")).expect("Could not open model from file");
@@ -85,7 +85,7 @@ fn upsample() -> ort::Result<()> {
fn upsample_with_ort_model() -> ort::Result<()> {
const IMAGE_TO_LOAD: &str = "mushroom.png";
ort::init().with_name("integration_test").with_log_level(LoggingLevel::Warning).commit()?;
ort::init().with_name("integration_test").commit()?;
let session_data =
std::fs::read(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests").join("data").join("upsample.ort")).expect("Could not open model from file");