LArDLHelper.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoradlcontent/LArHelpers/LArDLHelper.cc
3  *
4  * @brief Implementation of the lar deep learning helper helper class.
5  *
6  * $Log: $
7  */
8 
10 
11 namespace lar_dl_content
12 {
13 
14 using namespace pandora;
15 
17 {
18  try
19  {
20  model = torch::jit::load(filename);
21  std::cout << "Loaded the TorchScript model \'" << filename << "\'" << std::endl;
22  }
23  catch (...)
24  {
25  std::cout << "Error loading the TorchScript model \'" << filename << "\'" << std::endl;
26  return STATUS_CODE_FAILURE;
27  }
28 
29  return STATUS_CODE_SUCCESS;
30 }
31 
32 //------------------------------------------------------------------------------------------------------------------------------------------
33 
34 void LArDLHelper::InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
35 {
36  tensor = torch::zeros(dimensions);
37 }
38 
39 //------------------------------------------------------------------------------------------------------------------------------------------
40 
42 {
43  output = model.forward(input).toTensor();
44 }
45 
46 } // namespace lar_dl_content
std::string string
Definition: nybbler.cc:12
Definition: model.py:1
torch::jit::script::Module TorchModel
Definition: LArDLHelper.h:25
string filename
Definition: train.py:213
static int input(void)
Definition: code.cpp:15695
Header file for the lar deep learning helper helper class.
static void Forward(TorchModel &model, const TorchInputVector &input, TorchOutput &output)
Run a deep learning model.
Definition: LArDLHelper.cc:41
static pandora::StatusCode LoadModel(const std::string &filename, TorchModel &model)
Loads a deep learning model.
Definition: LArDLHelper.cc:16
static void InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
Create a torch input tensor.
Definition: LArDLHelper.cc:34
std::vector< torch::jit::IValue > TorchInputVector
Definition: LArDLHelper.h:27
QTextStream & endl(QTextStream &s)
def load(filename, jpath="depos")
Definition: depos.py:34