diff --git a/demo/demo/demo.cpp b/demo/demo/demo.cpp index afa5577..76b451d 100644 --- a/demo/demo/demo.cpp +++ b/demo/demo/demo.cpp @@ -111,7 +111,7 @@ int main(int argc, char *argv[]) { break; //inference - detNN->update(batch_dnn_input); + detNN->update(batch_dnn_input, n_batch); detNN->draw(batch_frame); if(show){ diff --git a/demo/demo/map.cpp b/demo/demo/map.cpp index 89f2c0f..aefc834 100644 --- a/demo/demo/map.cpp +++ b/demo/demo/map.cpp @@ -144,7 +144,7 @@ int main(int argc, char *argv[]) //inference detected_bbox.clear(); - detNN->update(batch_dnn_input, write_res_on_file, ×, write_coco_json); + detNN->update(batch_dnn_input,1,write_res_on_file, ×, write_coco_json); detNN->draw(batch_frames); detected_bbox = detNN->detected; diff --git a/include/tkDNN/DetectionNN.h b/include/tkDNN/DetectionNN.h index 3c56490..fc9a137 100644 --- a/include/tkDNN/DetectionNN.h +++ b/include/tkDNN/DetectionNN.h @@ -81,7 +81,7 @@ class DetectionNN { * * @param tensor_path path to the rt file og the NN. * @param n_classes number of classes for the given dataset. - * @param n_batches number of batches to use in inference + * @param n_batches maximum number of batches to use in inference * @return true if everything is correct, false otherwise. */ virtual bool init(const std::string& tensor_path, const int n_classes=80, const int n_batches=1) = 0; @@ -90,20 +90,23 @@ class DetectionNN { * This method performs the whole detection of the NN. * * @param frames frames to run detection on. + * @param cur_batches number of batches to use in inference * @param save_times if set to true, preprocess, inference and postprocess times * are saved on a csv file, otherwise not. * @param times pointer to the output stream where to write times * @param mAP set to true only if all the probabilities for a bounding * box are needed, as in some cases for the mAP calculation */ - void update(std::vector& frames, bool save_times=false, std::ofstream *times=nullptr, const bool mAP=false){ + void update(std::vector& frames, const int cur_batches=1, bool save_times=false, std::ofstream *times=nullptr, const bool mAP=false){ if(save_times && times==nullptr) FatalError("save_times set to true, but no valid ofstream given"); + if(cur_batches > nBatches) + FatalError("A batch size greater than nBatches cannot be used"); if(VERBOSE) printCenteredTitle(" TENSORRT detection ", '=', 30); { TIMER_START - for(int bi=0; biinput_dim; - dim.n = nBatches; + dim.n = cur_batches; { if(VERBOSE) dim.print(); TIMER_START @@ -129,7 +132,7 @@ class DetectionNN { batchDetected.clear(); { TIMER_START - for(int bi=0; bi