ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
IModel.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2
//
3
// SPDX-License-Identifier: GPL-3.0-or-later
4
5
#pragma once
6
#include "reusex/vision/IData.hpp"
7
#include "reusex/vision/IDataset.hpp"
8
9
#include <filesystem>
10
#include <span>
11
#include <vector>
12
13
namespace
reusex::vision
{
14
class
IModel
{
15
public
:
16
// virtual IModel(const std::filesystem::path &path) = 0;
17
18
/* The destructor is declared as virtual to ensure that when an object of a
19
* derived class is deleted through a pointer to the base class (IModel), the
20
* destructor of the derived class is called, allowing for proper cleanup of
21
* resources. This is important in C++ to prevent memory leaks and ensure that
22
* any resources allocated by the derived class are released correctly when
23
* the object is destroyed. */
24
virtual
~IModel
() =
default
;
25
26
/* The create function is a static member function that serves as a factory
27
* method for creating instances of classes that implement the IModel
28
* interface. It takes a file path as an argument, which is likely used to
29
* load a model from a file. The function returns a unique pointer to an
30
* IModel instance, allowing for dynamic memory management and ensuring that
31
* the created model is properly destroyed when it goes out of scope. This
32
* design allows for flexibility in creating different types of models based
33
* on the provided file path, while adhering to the IModel interface.
34
* @param model_path The file path to the model that needs to be created.
35
* @return A unique pointer to an instance of a class that implements the
36
* IModel interface.
37
*/
38
static
std::unique_ptr<IModel>
create
(
const
std::filesystem::path &model_path,
39
bool
use_gpu =
false
);
40
41
/* The forward function is a pure virtual function that must be implemented by
42
* any class that inherits from the IModel interface. It takes a span of
43
* IDataset::Pair objects as input and returns a vector of IDataset::Pair
44
* objects as output. This function is likely responsible for performing the
45
* forward pass of the model, processing the input data and producing the
46
* corresponding output. The use of std::span allows for efficient handling of
47
* contiguous sequences of data without the overhead of copying, while the
48
* return type of std::vector provides flexibility in managing the output
49
* data.
50
* @param input A span of IDataset::Pair objects representing the input data
51
* to be processed by the model.
52
* @return A vector of IDataset::Pair objects representing the output produced
53
* by the model after processing the input data.
54
*/
55
virtual
std::vector<IDataset::Pair>
56
forward
(
const
std::span<IDataset::Pair> &input) = 0;
57
58
// virtual void save(const std::string &path) const = 0;
59
// virtual std::vector<float> predict(const std::vector<float> &input) = 0;
60
};
61
}
// namespace reusex::vision
reusex::vision::IModel
Definition
IModel.hpp:14
reusex::vision::IModel::~IModel
virtual ~IModel()=default
reusex::vision::IModel::forward
virtual std::vector< IDataset::Pair > forward(const std::span< IDataset::Pair > &input)=0
reusex::vision::IModel::create
static std::unique_ptr< IModel > create(const std::filesystem::path &model_path, bool use_gpu=false)
reusex::vision
Definition
annotate.hpp:12
libs
reusex
include
vision
IModel.hpp
Generated by
1.17.0