diff --git a/CMakeLists.txt b/CMakeLists.txt index 02cbfa4bb..daebf8dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ option(ORT_DIRECTORY "User can specify the installed onnxruntime directory.") # Please don't open this flag now, some bugs exists. # option(ENABLE_OPENCV_CUDA "Whether to enable opencv with cuda, this will allow process image with GPU." OFF) -option(ENABLE_DEBUG "Whether to enable print debug information, this may reduce performance." OFF) # Whether to build fastdeply with vision/text/... examples, only for testings. option(BUILD_EXAMPLES "Whether to build fastdeply with vision examples" OFF) @@ -90,9 +89,6 @@ if(WIN32 AND ENABLE_VISION) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) endif() -if(ENABLE_DEBUG) - add_definitions(-DFASTDEPLOY_DEBUG) -endif() if(NOT CUDA_DIRECTORY) set(CUDA_DIRECTORY "/usr/local/cuda") endif() diff --git a/fastdeploy/core/config.h.in b/fastdeploy/core/config.h.in index 573439f60..d1e8702b1 100644 --- a/fastdeploy/core/config.h.in +++ b/fastdeploy/core/config.h.in @@ -13,10 +13,6 @@ // limitations under the License. #pragma once -#ifndef FASTDEPLOY_DEBUG -#cmakedefine FASTDEPLOY_DEBUG -#endif - #ifndef FASTDEPLOY_LIB #cmakedefine FASTDEPLOY_LIB #endif diff --git a/fastdeploy/fastdeploy_model.cc b/fastdeploy/fastdeploy_model.cc index bfe1c800a..7b7868a6b 100644 --- a/fastdeploy/fastdeploy_model.cc +++ b/fastdeploy/fastdeploy_model.cc @@ -200,18 +200,4 @@ std::map FastDeployModel::PrintStatisInfoOfRuntime() { statis_info_of_runtime_dict["iterations"] = time_of_runtime_.size(); return statis_info_of_runtime_dict; } - -void FastDeployModel::EnableDebug() { -#ifdef FASTDEPLOY_DEBUG - debug_ = true; -#else - FDWARNING << "The compile FastDeploy is not with -DENABLE_DEBUG=ON, so " - "cannot enable debug mode." - << std::endl; - debug_ = false; -#endif -} - -bool FastDeployModel::DebugEnabled() { return debug_; } - } // namespace fastdeploy diff --git a/fastdeploy/fastdeploy_model.h b/fastdeploy/fastdeploy_model.h index cf452aaac..cd373013a 100644 --- a/fastdeploy/fastdeploy_model.h +++ b/fastdeploy/fastdeploy_model.h @@ -54,30 +54,15 @@ class FASTDEPLOY_DECL FastDeployModel { } virtual std::map PrintStatisInfoOfRuntime(); - virtual void EnableDebug(); - virtual bool DebugEnabled(); private: std::unique_ptr runtime_; bool runtime_initialized_ = false; // whether to record inference time bool enable_record_time_of_runtime_ = false; - bool debug_ = false; // record inference time for backend std::vector time_of_runtime_; }; -#define TIMERECORD_START(id) \ - TimeCounter tc_##id; \ - tc_##id.Start(); - -#define TIMERECORD_END(id, prefix) \ - if (DebugEnabled()) { \ - tc_##id.End(); \ - FDLogger() << __FILE__ << "(" << __LINE__ << "):" << __FUNCTION__ << " " \ - << prefix << " duration = " << tc_##id.Duration() << "s." \ - << std::endl; \ - } - } // namespace fastdeploy diff --git a/fastdeploy/vision/detection/contrib/nanodet_plus.cc b/fastdeploy/vision/detection/contrib/nanodet_plus.cc index 1d29fc531..a779df500 100644 --- a/fastdeploy/vision/detection/contrib/nanodet_plus.cc +++ b/fastdeploy/vision/detection/contrib/nanodet_plus.cc @@ -302,10 +302,6 @@ bool NanoDetPlus::Postprocess( bool NanoDetPlus::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -322,31 +318,18 @@ bool NanoDetPlus::Predict(cv::Mat* im, DetectionResult* result, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors[0], result, im_info, conf_threshold, nms_iou_threshold)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/detection/contrib/yolov5.cc b/fastdeploy/vision/detection/contrib/yolov5.cc index b9be704c2..e678b3c14 100644 --- a/fastdeploy/vision/detection/contrib/yolov5.cc +++ b/fastdeploy/vision/detection/contrib/yolov5.cc @@ -256,9 +256,6 @@ bool YOLOv5::Postprocess( bool YOLOv5::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif Mat mat(*im); std::vector input_tensors(1); @@ -272,31 +269,18 @@ bool YOLOv5::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors, result, im_info, conf_threshold, nms_iou_threshold, multi_label_)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/detection/contrib/yolov5lite.cc b/fastdeploy/vision/detection/contrib/yolov5lite.cc index 87c1aff3d..fbd2978a8 100644 --- a/fastdeploy/vision/detection/contrib/yolov5lite.cc +++ b/fastdeploy/vision/detection/contrib/yolov5lite.cc @@ -339,9 +339,6 @@ bool YOLOv5Lite::Postprocess( bool YOLOv5Lite::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif Mat mat(*im); std::vector input_tensors(1); @@ -358,21 +355,12 @@ bool YOLOv5Lite::Predict(cv::Mat* im, DetectionResult* result, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (is_decode_exported) { if (!Postprocess(output_tensors[0], result, im_info, conf_threshold, @@ -387,10 +375,6 @@ bool YOLOv5Lite::Predict(cv::Mat* im, DetectionResult* result, return false; } } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/detection/contrib/yolov6.cc b/fastdeploy/vision/detection/contrib/yolov6.cc index 5f0182839..95d4010ed 100644 --- a/fastdeploy/vision/detection/contrib/yolov6.cc +++ b/fastdeploy/vision/detection/contrib/yolov6.cc @@ -214,10 +214,6 @@ bool YOLOv6::Postprocess( bool YOLOv6::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -234,31 +230,18 @@ bool YOLOv6::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors[0], result, im_info, conf_threshold, nms_iou_threshold)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/detection/contrib/yolox.cc b/fastdeploy/vision/detection/contrib/yolox.cc index 4380d5e3c..f90955d79 100644 --- a/fastdeploy/vision/detection/contrib/yolox.cc +++ b/fastdeploy/vision/detection/contrib/yolox.cc @@ -279,10 +279,6 @@ bool YOLOX::PostprocessWithDecode( bool YOLOX::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -299,21 +295,12 @@ bool YOLOX::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (is_decode_exported) { if (!Postprocess(output_tensors[0], result, im_info, conf_threshold, @@ -328,10 +315,6 @@ bool YOLOX::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold, return false; } } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/facedet/contrib/retinaface.cc b/fastdeploy/vision/facedet/contrib/retinaface.cc index dda6b9715..5e0fd6645 100644 --- a/fastdeploy/vision/facedet/contrib/retinaface.cc +++ b/fastdeploy/vision/facedet/contrib/retinaface.cc @@ -257,10 +257,6 @@ bool RetinaFace::Postprocess( bool RetinaFace::Predict(cv::Mat* im, FaceDetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -277,31 +273,18 @@ bool RetinaFace::Predict(cv::Mat* im, FaceDetectionResult* result, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors, result, im_info, conf_threshold, nms_iou_threshold)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/facedet/contrib/scrfd.cc b/fastdeploy/vision/facedet/contrib/scrfd.cc index b0bfd7a54..4602c3825 100644 --- a/fastdeploy/vision/facedet/contrib/scrfd.cc +++ b/fastdeploy/vision/facedet/contrib/scrfd.cc @@ -318,9 +318,6 @@ bool SCRFD::Postprocess( bool SCRFD::Predict(cv::Mat* im, FaceDetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif Mat mat(*im); std::vector input_tensors(1); @@ -337,31 +334,18 @@ bool SCRFD::Predict(cv::Mat* im, FaceDetectionResult* result, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors, result, im_info, conf_threshold, nms_iou_threshold)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/facedet/contrib/ultraface.cc b/fastdeploy/vision/facedet/contrib/ultraface.cc index 907a397f7..5aba23b9e 100644 --- a/fastdeploy/vision/facedet/contrib/ultraface.cc +++ b/fastdeploy/vision/facedet/contrib/ultraface.cc @@ -168,10 +168,6 @@ bool UltraFace::Postprocess( bool UltraFace::Predict(cv::Mat* im, FaceDetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -187,32 +183,18 @@ bool UltraFace::Predict(cv::Mat* im, FaceDetectionResult* result, FDERROR << "Failed to preprocess input image." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors, result, im_info, conf_threshold, nms_iou_threshold)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/facedet/contrib/yolov5face.cc b/fastdeploy/vision/facedet/contrib/yolov5face.cc index 1a02b0919..cc8d3ce83 100644 --- a/fastdeploy/vision/facedet/contrib/yolov5face.cc +++ b/fastdeploy/vision/facedet/contrib/yolov5face.cc @@ -241,10 +241,6 @@ bool YOLOv5Face::Postprocess( bool YOLOv5Face::Predict(cv::Mat* im, FaceDetectionResult* result, float conf_threshold, float nms_iou_threshold) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -260,32 +256,18 @@ bool YOLOv5Face::Predict(cv::Mat* im, FaceDetectionResult* result, FDERROR << "Failed to preprocess input image." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors[0], result, im_info, conf_threshold, nms_iou_threshold)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/faceid/contrib/insightface_rec.cc b/fastdeploy/vision/faceid/contrib/insightface_rec.cc index 89ff6a004..006568255 100644 --- a/fastdeploy/vision/faceid/contrib/insightface_rec.cc +++ b/fastdeploy/vision/faceid/contrib/insightface_rec.cc @@ -109,10 +109,6 @@ bool InsightFaceRecognitionModel::Postprocess( bool InsightFaceRecognitionModel::Predict(cv::Mat* im, FaceRecognitionResult* result) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -121,30 +117,17 @@ bool InsightFaceRecognitionModel::Predict(cv::Mat* im, return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors, result)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; } diff --git a/fastdeploy/vision/matting/contrib/modnet.cc b/fastdeploy/vision/matting/contrib/modnet.cc index 4343abd7a..1d30e0b6a 100644 --- a/fastdeploy/vision/matting/contrib/modnet.cc +++ b/fastdeploy/vision/matting/contrib/modnet.cc @@ -126,10 +126,6 @@ bool MODNet::Postprocess( } bool MODNet::Predict(cv::Mat* im, MattingResult* result) { -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_START(0) -#endif - Mat mat(*im); std::vector input_tensors(1); @@ -142,31 +138,17 @@ bool MODNet::Predict(cv::Mat* im, MattingResult* result) { FDERROR << "Failed to preprocess input image." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(0, "Preprocess") - TIMERECORD_START(1) -#endif - input_tensors[0].name = InputInfoOfRuntime(0).name; std::vector output_tensors; if (!Infer(input_tensors, &output_tensors)) { FDERROR << "Failed to inference." << std::endl; return false; } -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(1, "Inference") - TIMERECORD_START(2) -#endif if (!Postprocess(output_tensors, result, im_info)) { FDERROR << "Failed to post process." << std::endl; return false; } - -#ifdef FASTDEPLOY_DEBUG - TIMERECORD_END(2, "Postprocess") -#endif return true; }