|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef INSTANCE_BANK_H
19 #define INSTANCE_BANK_H
21 #include <torch/torch.h>
23 #include "../utils/log_utils.h"
24 #include "../utils/tensor.h"
45 const torch::Tensor& anchors,
46 const std::vector<torch::Tensor>& transforms,
47 const std::vector<torch::Tensor>& time_intervals) = 0;
52 typedef std::map<std::string, torch::jit::IValue>
MetaData;
82 const torch::Tensor& anchor,
84 int num_temp_instances = 0,
85 float default_time_interval = 0.5,
86 float confidence_decay = 0.6,
87 bool anchor_grad =
true,
88 bool feat_grad =
true,
89 float max_time_interval = 2.0,
111 std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
122 std::tuple<torch::Tensor, torch::Tensor>
123 update(torch::Tensor instance_feature, torch::Tensor anchor, torch::Tensor confidence);
135 torch::Tensor instance_feature,
136 torch::Tensor anchor,
137 torch::Tensor confidence,
139 const std::vector<torch::Tensor>* feature_maps =
nullptr);
150 torch::Tensor confidence,
151 torch::Tensor anchor = torch::Tensor(),
152 float threshold = -1.0);
161 torch::Tensor instance_id_tensor,
162 torch::Tensor confidence = torch::Tensor());
178 int m_num_temp_instances;
179 float m_default_time_interval;
180 float m_confidence_decay;
181 float m_max_time_interval;
185 torch::Tensor m_anchor;
186 torch::Tensor m_anchor_init;
187 torch::Tensor m_instance_feature;
188 torch::Tensor m_reid_feature;
191 torch::Tensor m_cached_feature;
192 torch::Tensor m_cached_anchor;
194 torch::Tensor m_mask;
195 torch::Tensor m_confidence;
196 torch::Tensor m_temp_confidence;
197 torch::Tensor m_instance_id;
201 torch::Device m_device;
210 torch::Tensor
load_anchor(
const std::string& filename);
212 #endif // INSTANCE_BANK_H
void update_instance_id(torch::Tensor instance_id_tensor, torch::Tensor confidence=torch::Tensor())
Update instance IDs based on confidence scores.
std::tuple< torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor > get(int batch_size, const MetaData &metas, const DNMetaData *dn_metas=nullptr)
Get features, anchors and time intervals for the current batch.
std::tuple< torch::Tensor, torch::Tensor > update(torch::Tensor instance_feature, torch::Tensor anchor, torch::Tensor confidence)
Update instance features and anchors.
InstanceBank class for managing and tracking object instances across frames.
torch::Tensor getMask() const
Get the mask tensor.
Interface class for anchor projection operations.
std::map< std::string, torch::Tensor > DNMetaData
virtual std::vector< torch::Tensor > anchor_projection(const torch::Tensor &anchors, const std::vector< torch::Tensor > &transforms, const std::vector< torch::Tensor > &time_intervals)=0
Project anchors using transformation matrices and time intervals.
torch::Tensor load_anchor(const std::string &filename)
Load anchor data from a NumPy .npy file.
torch::Tensor get_instance_id(torch::Tensor confidence, torch::Tensor anchor=torch::Tensor(), float threshold=-1.0)
Get instance IDs based on confidence scores.
void init_weight()
Initialize weights with proper initialization schemes.
void reset()
Reset internal state.
InstanceBank(int num_anchor, int embed_dims, const torch::Tensor &anchor, AnchorHandler *anchor_handler=nullptr, int num_temp_instances=0, float default_time_interval=0.5, float confidence_decay=0.6, bool anchor_grad=true, bool feat_grad=true, float max_time_interval=2.0, int reid_dims=-1, int gpu_id=-1)
Constructor for InstanceBank.
virtual ~AnchorHandler()=default
void cache(torch::Tensor instance_feature, torch::Tensor anchor, torch::Tensor confidence, const MetaData *metas=nullptr, const std::vector< torch::Tensor > *feature_maps=nullptr)
Cache features, anchors and metadata for temporal association.
std::map< std::string, torch::jit::IValue > MetaData