6 #include <torch/torch.h> 51 const vector<vector<size_t>>& idsmap,
52 const vector<NuGraphOutput>& infer_output)
override;
72 for (
auto& v : idsmap)
74 std::array<float, 5> arr;
82 const vector<vector<size_t>>& idsmap,
83 const vector<NuGraphOutput>& infer_output)
90 for (
auto& v : idsmap)
92 std::array<float, 5> arr;
97 for (
size_t p = 0; p <
planes.size(); p++) {
99 const std::vector<float>* x_semantic_data = 0;
100 for (
auto& io : infer_output) {
101 if (io.output_name ==
outputname +
planes[p]) x_semantic_data = &io.output_vec;
108 torch::TensorOptions options = torch::TensorOptions().dtype(torch::kFloat32);
109 size_t n_rows = x_semantic_data->size() / n_cols;
110 const torch::Tensor s =
111 torch::from_blob(const_cast<float*>(x_semantic_data->data()),
112 {
static_cast<int64_t
>(n_rows), static_cast<int64_t>(n_cols)},
115 for (
int i = 0; i < s.sizes()[0]; ++i) {
116 size_t idx = idsmap[p][i];
117 std::array<float, 5> input;
118 for (
size_t j = 0; j < n_cols; ++j)
119 input[j] = s[i][j].item<float>();
122 (*semtcol)[idx] = semt;
void writeToEvent(art::Event &e, const vector< vector< size_t >> &idsmap, const vector< NuGraphOutput > &infer_output) override
Decoder function.
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
T get(std::string const &key) const
SemanticDecoder(const fhicl::ParameterSet &pset)
Constructor.
std::vector< std::string > categories
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
void writeEmptyToEvent(art::Event &e, const vector< vector< size_t >> &idsmap) override
writeEmptyToEvent function
virtual ~SemanticDecoder() noexcept=default
Virtual Destructor.
void declareProducts(art::ProducesCollector &collector) override
declareProducts function