ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
Yolo.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/IModel.hpp"
7
#include "reusex/vision/libtorch/Data.hpp"
8
9
#include <torch/script.h>
10
#include <torch/torch.h>
11
12
#include <filesystem>
13
#include <memory>
14
#include <span>
15
#include <vector>
16
17
namespace
reusex::vision::libtorch
{
18
24
class
LibTorchYolo
:
public
IModel
{
25
public
:
30
explicit
LibTorchYolo
(
const
std::filesystem::path &model_path,
31
bool
use_cuda =
false
);
32
38
static
std::unique_ptr<LibTorchYolo>
39
create
(
const
std::filesystem::path &model_path,
bool
use_cuda =
false
);
40
49
std::vector<IDataset::Pair>
50
forward
(
const
std::span<IDataset::Pair> &input)
override
;
51
52
private
:
57
torch::Tensor
58
images_to_tensor(
const
std::vector<const LibTorchData *> &inputs)
const
;
59
60
torch::jit::script::Module model_;
61
torch::Device device_;
62
};
63
64
}
// namespace reusex::vision::libtorch
reusex::vision::IModel
Definition
IModel.hpp:10
reusex::vision::libtorch::LibTorchYolo::forward
std::vector< IDataset::Pair > forward(const std::span< IDataset::Pair > &input) override
Run YOLO inference on a batch of images.
reusex::vision::libtorch::LibTorchYolo::LibTorchYolo
LibTorchYolo(const std::filesystem::path &model_path, bool use_cuda=false)
Construct and load a YOLO model from a TorchScript file.
reusex::vision::libtorch::LibTorchYolo::create
static std::unique_ptr< LibTorchYolo > create(const std::filesystem::path &model_path, bool use_cuda=false)
Factory method for creating a LibTorchYolo instance.
reusex::vision::libtorch
Definition
Backend.hpp:10
libs
reusex
include
vision
libtorch
Yolo.hpp
Generated by
1.17.0