Loading...
Searching...
No Matches
non_max_suppression_layer.h
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 Artificial Intelligence Techniques, S.L. and Roberto López González
3
4#pragma once
5
8
9namespace opennn
10{
11
13{
14 Index grid_size = 0;
15 Index grid_width = 0;
16 Index boxes_per_cell = 0;
17 Index classes_number = 0;
19 float iou_threshold = 0.4f;
20
21 void set(const Shape&,
22 Index,
23 float,
24 float);
25
27
28private:
29 void apply(const TensorView&, TensorView&) const;
30};
31
32class NonMaxSuppression final : public Layer
33{
34public:
35
37 Index boxes_per_cell = 1,
38 float confidence_threshold = 0.5f,
39 float iou_threshold = 0.4f,
40 const string& = "non_max_suppression_layer");
41
42 Shape get_output_shape() const override;
43
44 void set(const Shape&,
45 Index,
46 float,
47 float,
48 const string&);
49
50 bool accepts_input_rank(Index rank) const override { return is_one_of(rank, 3); }
51
53 {
55 "{} layer supports FP32 activations only; compile the network with Type::FP32.",
56 get_name());
57 }
58
59 void apply_input_shape(const Shape&) override;
60
61 float get_confidence_threshold() const { return nms.confidence_threshold; }
62 void set_confidence_threshold(float t) { nms.confidence_threshold = t; }
63
64 void read_JSON_body(const Json*) override;
65 void write_JSON_body(JsonWriter&) const override;
66
67private:
68
70
71 void configure_operator();
72};
73
74}
Definition json.h:92
Definition json.h:24
Type get_compute_dtype() const noexcept
Definition layer.h:157
Layer(LayerType type, Trainability trainability=Trainability::Trainable)
Definition layer.h:210
const string & get_name() const
float get_confidence_threshold() const
Definition non_max_suppression_layer.h:61
void write_JSON_body(JsonWriter &) const override
Shape get_output_shape() const override
void set_confidence_threshold(float t)
Definition non_max_suppression_layer.h:62
bool accepts_input_rank(Index rank) const override
Definition non_max_suppression_layer.h:50
NonMaxSuppression(const Shape &={}, Index boxes_per_cell=1, float confidence_threshold=0.5f, float iou_threshold=0.4f, const string &="non_max_suppression_layer")
void read_JSON_body(const Json *) override
void apply_input_shape(const Shape &) override
void on_compute_dtype_changed() override
Definition non_max_suppression_layer.h:52
void set(const Shape &, Index, float, float, const string &)
Definition configuration.h:10
constexpr bool is_one_of(const T &value, const Candidates &... candidates)
Definition opennn_types.h:273
@ FP32
Definition configuration.h:13
ForwardPropagationMode
Definition forward_propagation.h:33
#define throw_if(condition,...)
Definition opennn_types.h:243
Definition forward_propagation.h:52
Definition non_max_suppression_layer.h:13
Index grid_size
Definition non_max_suppression_layer.h:14
Index boxes_per_cell
Definition non_max_suppression_layer.h:16
void set(const Shape &, Index, float, float)
Index classes_number
Definition non_max_suppression_layer.h:17
void forward_propagate(ForwardPropagation &, size_t, ForwardPropagationMode) override
float iou_threshold
Definition non_max_suppression_layer.h:19
Index grid_width
Definition non_max_suppression_layer.h:15
float confidence_threshold
Definition non_max_suppression_layer.h:18
Definition operator.h:28
Definition tensor_types.h:172
Definition tensor_types.h:540