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