Skip to content

Commit

Permalink
[Bug Fix] fixed ppdet postprocess empty result error (PaddlePaddle#691)
Browse files Browse the repository at this point in the history
* [Android] Add CxxBuffer to native PaddleSegModel

* [Android] Add PaddleSeg android app example

* [Android] Add SCRFD android app example

* [Doc] fix typos

* [Android] revert camera setting changes

* [Bug Fix] fixed ppdet postprocess empty result error
  • Loading branch information
DefTruth authored Nov 24, 2022
1 parent c18a9e3 commit 256f7c2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ if(MSVC)
# disable warnings for dll export
target_compile_options(${LIBRARY_NAME} PRIVATE "$<$<BUILD_INTERFACE:$<COMPILE_LANGUAGE:CXX>>:/wd4251>$<$<BUILD_INTERFACE:$<COMPILE_LANGUAGE:CUDA>>:-Xcompiler=/wd4251>")
endif()

if (ANDROID)
find_library(log-lib log)
list(APPEND DEPEND_LIBS ${log-lib})
endif()

target_link_libraries(${LIBRARY_NAME} ${DEPEND_LIBS})

if(WIN32)
Expand Down
7 changes: 7 additions & 0 deletions fastdeploy/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ namespace fastdeploy {
FDLogger::FDLogger(bool verbose, const std::string& prefix) {
verbose_ = verbose;
line_ = "";
#ifdef __ANDROID__
prefix_ = std::string("[FastDeploy]") + prefix;
#else
prefix_ = prefix;
#endif
}

FDLogger& FDLogger::operator<<(std::ostream& (*os)(std::ostream&)) {
if (!verbose_) {
return *this;
}
std::cout << prefix_ << " " << line_ << std::endl;
#ifdef __ANDROID__
__android_log_print(ANDROID_LOG_INFO, prefix_.c_str(), "%s", line_.c_str());
#endif
line_ = "";
return *this;
}
Expand Down
9 changes: 9 additions & 0 deletions fastdeploy/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <string>
#include <vector>

#ifdef __ANDROID__
#include <android/log.h> // NOLINT
#endif

#if defined(_WIN32)
#ifdef FASTDEPLOY_LIB
#define FASTDEPLOY_DECL __declspec(dllexport)
Expand Down Expand Up @@ -54,10 +58,15 @@ class FASTDEPLOY_DECL FDLogger {
line_ += ss.str();
return *this;
}

FDLogger& operator<<(std::ostream& (*os)(std::ostream&));

~FDLogger() {
if (!verbose_ && line_ != "") {
std::cout << line_ << std::endl;
#ifdef __ANDROID__
__android_log_print(ANDROID_LOG_INFO, prefix_.c_str(), "%s", line_.c_str());
#endif
}
}

Expand Down
12 changes: 6 additions & 6 deletions fastdeploy/vision/detection/ppdet/postprocessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ bool PaddleDetPostprocessor::Run(const std::vector<FDTensor>& tensors,
tensors[0].shape.size());
return ProcessUnDecodeResults(tensors, results);
}

if (tensors[0].shape[0] == 0) {
// No detected boxes
return true;
}

// Get number of boxes for each input image
std::vector<int> num_boxes(tensors[1].shape[0]);
int total_num_boxes = 0;
Expand Down Expand Up @@ -114,6 +108,12 @@ bool PaddleDetPostprocessor::Run(const std::vector<FDTensor>& tensors,

// Get boxes for each input image
results->resize(num_boxes.size());

if (tensors[0].shape[0] == 0) {
// No detected boxes
return true;
}

const auto* box_data = static_cast<const float*>(tensors[0].CpuData());
int offset = 0;
for (size_t i = 0; i < num_boxes.size(); ++i) {
Expand Down

0 comments on commit 256f7c2

Please sign in to comment.