May 2020
Intermediate to advanced
530 pages
17h 8m
English
The core of our application is the server. Let's assume that we've already implemented image classification in the same way we did in the previous section, that is, by using a model saved as a TorchScript snapshot and loaded into the torch::jit::script::Module object. We encapsulated this functionality in the following class:
class Network { public: Network(const std::string& snapshot_path, const std::string& synset_path, torch::DeviceType device_type); std::string Classify(const at::Tensor& image); private: torch::DeviceType device_type_; Classes classes_; torch::jit::script::Module model_;};
The following code shows an implementation of the main routine of our application:
#include <torch/script.h>#include "network.h"#include ...
Read now
Unlock full access