Loading...
Searching...
No Matches
detection_v8_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
9
10namespace opennn
11{
12
14{
15 Index grid_size = 0;
16 Index grid_width = 0;
17 Index classes_number = 0;
18 Index reg_max = 1;
19
20 void set(const Shape&, Index reg_max);
21
23 void back_propagate(ForwardPropagation&, BackPropagation&, size_t) const override;
24};
25
26class DetectionV8 final : public Layer, public DetectionHeadEndpoint
27{
28public:
29
30 DetectionV8(const Shape& = {}, const string& = "detection_v8");
31 DetectionV8(const Shape&, Index reg_max, const string& = "detection_v8");
32
33 Shape get_output_shape() const override { return input_shape; }
34 Index get_classes_number() const { return detection.classes_number; }
36 {
38 1,
39 detection.classes_number,
40 detection.reg_max,
42 }
43
44 void set(const Shape&, const string&);
45 void set(const Shape&, Index reg_max, const string&);
46 bool accepts_input_rank(Index rank) const override { return is_one_of(rank, 3); }
47
49 {
51 "{} layer supports FP32 activations only; compile the network with Type::FP32.",
52 get_name());
53 }
54
55 void apply_input_shape(const Shape& new_input_shape) override { set(new_input_shape, detection.reg_max, label); }
56
57 void read_JSON_body(const Json*) override;
58 void write_JSON_body(JsonWriter&) const override;
59
60private:
61
62 DetectionV8Operator detection;
63
64 void configure_operator();
65};
66
67}
Definition detection_head.h:60
void apply_input_shape(const Shape &new_input_shape) override
Definition detection_v8_layer.h:55
void write_JSON_body(JsonWriter &) const override
void on_compute_dtype_changed() override
Definition detection_v8_layer.h:48
bool accepts_input_rank(Index rank) const override
Definition detection_v8_layer.h:46
void set(const Shape &, Index reg_max, const string &)
DetectionHeadMetadata get_detection_head_metadata() const noexcept override
Definition detection_v8_layer.h:35
void read_JSON_body(const Json *) override
DetectionV8(const Shape &, Index reg_max, const string &="detection_v8")
DetectionV8(const Shape &={}, const string &="detection_v8")
Shape get_output_shape() const override
Definition detection_v8_layer.h:33
void set(const Shape &, const string &)
Index get_classes_number() const
Definition detection_v8_layer.h:34
Definition json.h:92
Definition json.h:24
Type get_compute_dtype() const noexcept
Definition layer.h:157
string label
Definition layer.h:215
Layer(LayerType type, Trainability trainability=Trainability::Trainable)
Definition layer.h:210
const string & get_name() const
Shape input_shape
Definition layer.h:219
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
@ Sigmoid
Definition detection_head.h:14
ForwardPropagationMode
Definition forward_propagation.h:33
@ AnchorFree
Definition detection_head.h:13
#define throw_if(condition,...)
Definition opennn_types.h:243
Definition back_propagation.h:19
Definition detection_head.h:17
Definition detection_v8_layer.h:14
void back_propagate(ForwardPropagation &, BackPropagation &, size_t) const override
void forward_propagate(ForwardPropagation &, size_t, ForwardPropagationMode) override
Index grid_width
Definition detection_v8_layer.h:16
Index classes_number
Definition detection_v8_layer.h:17
void set(const Shape &, Index reg_max)
Index reg_max
Definition detection_v8_layer.h:18
Index grid_size
Definition detection_v8_layer.h:15
Definition forward_propagation.h:52
Definition operator.h:28
Definition tensor_types.h:172