Skip to content

Commit

Permalink
Merge pull request #7 from PaddlePaddle/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
felixhjh authored Jul 28, 2022
2 parents 19f23e6 + a9b5c6e commit 9031454
Show file tree
Hide file tree
Showing 30 changed files with 961 additions and 20 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ option(ENABLE_DEBUG "if to enable print debug information, this may reduce perfo
# Whether to build fastdeply with vision/text/... examples, only for testings.
option(WITH_VISION_EXAMPLES "Whether to build fastdeply with vision examples" OFF)

# Check for 32bit system
if(WIN32)
if(NOT CMAKE_CL_64)
message("***********************Compile on non 64-bit system now**********************")
add_definitions(-DNON_64_PLATFORM)
if(WITH_GPU)
message(FATAL_ERROR "-DWITH_GPU=ON doesn't support on non 64-bit system now.")
endif()
if(ENABLE_PADDLE_BACKEND)
message(FATAL_ERROR "-DENABLE_PADDLE_BACKEND=ON doesn't support on non 64-bit system now.")
endif()
if(ENABLE_VISION)
message(FATAL_ERROR "-DENABLE_VISION=ON doesn't support on non 64-bit system now.")
endif()
endif()
endif()

if(ENABLE_DEBUG)
add_definitions(-DFASTDEPLOY_DEBUG)
endif()
Expand Down
4 changes: 4 additions & 0 deletions csrcs/fastdeploy/backends/ort/ops/multiclass_nms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NON_64_PLATFORM

#include "fastdeploy/backends/ort/ops/multiclass_nms.h"
#include <algorithm>
#include "fastdeploy/core/fd_tensor.h"
Expand Down Expand Up @@ -255,3 +257,5 @@ void MultiClassNmsKernel::GetAttribute(const OrtKernelInfo* info) {
score_threshold = ort_.KernelInfoGetAttribute<float>(info, "score_threshold");
}
} // namespace fastdeploy

#endif
5 changes: 5 additions & 0 deletions csrcs/fastdeploy/backends/ort/ops/multiclass_nms.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// limitations under the License.

#pragma once

#include <map>

#ifndef NON_64_PLATFORM
#include "onnxruntime_cxx_api.h" // NOLINT

namespace fastdeploy {
Expand Down Expand Up @@ -74,3 +77,5 @@ struct MultiClassNmsOp
};

} // namespace fastdeploy

#endif
2 changes: 2 additions & 0 deletions csrcs/fastdeploy/backends/ort/ort_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ TensorInfo OrtBackend::GetOutputInfo(int index) {
}

void OrtBackend::InitCustomOperators() {
#ifndef NON_64_PLATFORM
if (custom_operators_.size() == 0) {
MultiClassNmsOp* custom_op = new MultiClassNmsOp{};
custom_operators_.push_back(custom_op);
Expand All @@ -300,6 +301,7 @@ void OrtBackend::InitCustomOperators() {
custom_op_domain_.Add(custom_operators_[i]);
}
session_options_.Add(custom_op_domain_);
#endif
}

} // namespace fastdeploy
2 changes: 2 additions & 0 deletions csrcs/fastdeploy/backends/ort/ort_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class OrtBackend : public BaseBackend {
std::shared_ptr<Ort::IoBinding> binding_;
std::vector<OrtValueInfo> inputs_desc_;
std::vector<OrtValueInfo> outputs_desc_;
#ifndef NON_64_PLATFORM
Ort::CustomOpDomain custom_op_domain_ = Ort::CustomOpDomain("Paddle");
#endif
OrtBackendOption option_;
void CopyToCpu(const Ort::Value& value, FDTensor* tensor);
};
Expand Down
1 change: 1 addition & 0 deletions csrcs/fastdeploy/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "fastdeploy/core/config.h"
#ifdef ENABLE_VISION
#include "fastdeploy/vision/biubug6/retinaface.h"
#include "fastdeploy/vision/deepcam/yolov5face.h"
#include "fastdeploy/vision/linzaer/ultraface.h"
#include "fastdeploy/vision/megvii/yolox.h"
Expand Down
40 changes: 40 additions & 0 deletions csrcs/fastdeploy/vision/biubug6/biubug6_pybind.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy/pybind/main.h"

namespace fastdeploy {
void BindBiubug6(pybind11::module& m) {
auto biubug6_module = m.def_submodule(
"biubug6", "https://github.com/biubug6/Pytorch_Retinaface");
pybind11::class_<vision::biubug6::RetinaFace, FastDeployModel>(biubug6_module,
"RetinaFace")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def("predict",
[](vision::biubug6::RetinaFace& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {
auto mat = PyArrayToCvMat(data);
vision::FaceDetectionResult res;
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
return res;
})
.def_readwrite("size", &vision::biubug6::RetinaFace::size)
.def_readwrite("variance", &vision::biubug6::RetinaFace::variance)
.def_readwrite("downsample_strides",
&vision::biubug6::RetinaFace::downsample_strides)
.def_readwrite("min_sizes", &vision::biubug6::RetinaFace::min_sizes)
.def_readwrite("landmarks_per_face",
&vision::biubug6::RetinaFace::landmarks_per_face);
}
} // namespace fastdeploy
Loading

0 comments on commit 9031454

Please sign in to comment.