|
CNum 0.2.1
CPU-optimized ML library for C++
|
A REST API for making predictions with CNum models. More...
#include <Deploy.h>
Public Member Functions | |
| InferenceAPI (::std::string path, PreprocessFunction preprocess, PostprocessFunction postprocess, ::std::string allowed_origins="*", size_t n_models=20, unsigned short port=18080) | |
| Constructor. | |
| template<PathString Path> | |
| constexpr void | add_inference_route (crow::HTTPMethod method, InferenceRouteFunction route) |
| Add a route to the API that uses a model. | |
| template<PathString Path> | |
| constexpr void | add_regular_route (crow::HTTPMethod method, RegularRouteFunction route) |
| Add a route that doesn't use a model. | |
| void | start () |
| Start the backend. | |
A REST API for making predictions with CNum models.
| ModelType | The type of CNum model to use for the model pool |
| Storage | A struct containing all of the data from the preprocessing that also needs to be used in the postprocessing |
| CNum::Deploy::InferenceAPI< ModelType, Storage >::InferenceAPI | ( | ::std::string | path, |
| PreprocessFunction | preprocess, | ||
| PostprocessFunction | postprocess, | ||
| ::std::string | allowed_origins = "*", | ||
| size_t | n_models = 20, | ||
| unsigned short | port = 18080 ) |
Constructor.
| path | The path to the trained CNum model (".cmod") |
| preprocess | The function used to preprocess the data received in the request to the '/predict' route |
| postprocess | The function used process the predictions of the model into what is returned in the response |
| allowed_origins | The allowed origins for the API CORS header |
| n_models | The number of model instances in the ModelPool |
| port | The port to which the API listens |
|
constexpr |
Add a route to the API that uses a model.
| Path | The path for the new route |
| method | The HTTP method of the route (See Crow C++ documentation) |
| route | The actual middleware |
|
constexpr |
Add a route that doesn't use a model.
| Path | The path for the new route |
| method | The HTTP method of the route (See Crow C++ documentation) |
| route | The actual middleware |
| void CNum::Deploy::InferenceAPI< ModelType, Storage >::start | ( | ) |
Start the backend.