SOPT
Sparse OPTimisation
Typedefs | Functions
tf_model.cc File Reference
#include <iostream>
#include <vector>
#include <catch2/catch_all.hpp>
#include "sopt/logging.h"
#include "sopt/types.h"
#include "sopt/utilities.h"
#include "sopt/ort_session.h"
#include "tools_for_tests/directories.h"
#include "tools_for_tests/tiffwrappers.h"
+ Include dependency graph for tf_model.cc:

Go to the source code of this file.

Typedefs

using Scalar = double
 
using Image = sopt::Image< Scalar >
 
using Vector = sopt::Vector< Scalar >
 

Functions

 TEST_CASE ("Cppflow Model")
 

Typedef Documentation

◆ Image

Definition at line 17 of file tf_model.cc.

◆ Scalar

using Scalar = double

Definition at line 16 of file tf_model.cc.

◆ Vector

Definition at line 18 of file tf_model.cc.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Cppflow Model"  )

Definition at line 21 of file tf_model.cc.

21  {
22 
23  // read in image
24  const std::string input_image = "cameraman256";
25  const Image image = sopt::tools::read_standard_tiff(input_image);
26 
27  const int image_rows = image.rows();
28  const int image_cols = image.cols();
29 
30  // Read in model
31  const std::string path(sopt::tools::models_directory() + "/snr_15_model_dynamic.onnx");
32  sopt::ORTsession model(path);
33 
34  // Run model on image
35  const Image output_image = model.compute(image, {1,image_rows,image_cols,1});
36 
37  // compare input image to cleaned output image
38  // calculate mean squared error sum_i ( ( x_true(i) - x_est(i) ) **2 )
39  // check this is less than the number of pixels * 0.01
40 
41  auto mse = (image - output_image).square().sum() / image.size();
42  CAPTURE(mse);
43  CHECK(mse < 0.01);
44 
45 }
Sopt interface class to hold a ONNXrt session.
Definition: ort_session.h:18
Image read_standard_tiff(std::string const &name)
Reads tiff image from sopt data directory if it exists.
Definition: tiffwrappers.cc:9
std::string models_directory()
Machine-learning models.
sopt::Image< Scalar > Image
Definition: inpainting.cc:30

References sopt::ORTsession::compute(), sopt::tools::models_directory(), and sopt::tools::read_standard_tiff().