Skip to content

Commit

Permalink
feat(dlib): update dlib backend
Browse files Browse the repository at this point in the history
A few more tweaks to fix dlib integration regressions

Added additional build option to optionally enable AVX build mode for dlib

Updated dlib and fixed regression with dlib_actions.h

Bugfix for dlib integration regression
  • Loading branch information
cchadowitz authored and mergify[bot] committed Aug 29, 2022
1 parent 7172314 commit 12d181f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ option(USE_DLIB_CPU_ONLY "use DLIB without CUDA" OFF)
option(USE_CAFFE2_CPU_ONLY "use CAFFE2 without CUDA" OFF)
option(USE_FAISS_CPU_ONLY "use FAISS without CUDA" OFF)

# Dlib AVX option
option(USE_DLIB_AVX "build dlib with AVX enabled" OFF)

# Deprecated flag
if (USE_XGBOOST_GPU)
set(USE_XGBOOST_CPU_ONLY OFF)
Expand Down Expand Up @@ -379,7 +382,7 @@ if (USE_DLIB)
# Dlib

# Currently supported release version of dlib
set(DLIB_RELEASE_VERSION v19.18)
set(DLIB_RELEASE_VERSION v19.24)
message(STATUS "Using Dlib version ${DLIB_RELEASE_VERSION}")
add_definitions(-DUSE_DLIB)
set(DLIB_LIB_DEPS -ldlib -lopenblas)
Expand All @@ -389,7 +392,7 @@ if (USE_DLIB)
dlib
PREFIX dlib
URL https://github.com/davisking/dlib/archive/${DLIB_RELEASE_VERSION}.tar.gz
CONFIGURE_COMMAND cd dlib && mkdir -p build && cd build && cmake .. -DDLIB_NO_GUI_SUPPORT=ON -DDLIB_USE_CUDA=OFF -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dlib/build && cmake --build . --config Release --target install
CONFIGURE_COMMAND cd dlib && mkdir -p build && cd build && cmake .. -DUSE_AVX_INSTRUCTIONS=${USE_DLIB_AVX} -DDLIB_NO_GUI_SUPPORT=ON -DDLIB_USE_CUDA=OFF -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dlib/build && cmake --build . --config Release --target install
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
Expand All @@ -402,7 +405,7 @@ if (USE_DLIB)
dlib
PREFIX dlib
URL https://github.com/davisking/dlib/archive/${DLIB_RELEASE_VERSION}.tar.gz
CONFIGURE_COMMAND cd dlib && mkdir -p build && cd build && cmake .. -DDLIB_NO_GUI_SUPPORT=ON -DDLIB_USE_CUDA=ON -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dlib/build && cmake --build . --config Release --target install
CONFIGURE_COMMAND cd dlib && mkdir -p build && cd build && cmake .. -DUSE_AVX_INSTRUCTIONS=${USE_DLIB_AVX} -DDLIB_NO_GUI_SUPPORT=ON -DDLIB_USE_CUDA=ON -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dlib/build && cmake --build . --config Release --target install
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
Expand Down Expand Up @@ -1291,6 +1294,7 @@ message(STATUS "USE_HDF5: ${USE_HDF5}")
message(STATUS "USE_TENSORRT: ${USE_TENSORRT}")
message(STATUS "USE_DLIB: ${USE_DLIB}")
message(STATUS "USE_DLIB_CPU_ONLY: ${USE_DLIB_CPU_ONLY}")
message(STATUS "USE_DLIB_AVX: ${USE_DLIB_AVX}")
message(STATUS "USE_ANNOY: ${USE_ANNOY}")
message(STATUS "USE_FAISS: ${USE_FAISS}")
message(STATUS "USE_FAISS_CPU_ONLY: ${USE_FAISS_CPU_ONLY}")
Expand Down
5 changes: 3 additions & 2 deletions src/backends/dlib/dlib_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ namespace dd
std::vector<std::string> bbox_ids;

// check for action parameters
double bratio
= _params->padding_ratio != nullptr ? _params->padding_ratio : 0.25;
double bratio = _params->padding_ratio;
if (bratio == 0.0)
bratio = 0.25; // Default is 0.25 for DlibAlignCropAction
int chip_size = _params->chip_size;
std::vector<APIData> cvad;

Expand Down
4 changes: 1 addition & 3 deletions src/backends/dlib/dlib_actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ namespace dd
{
public:
DlibAlignCropAction(oatpp::Object<DTO::ChainCall> call_dto,
const std::string &action_id,
const std::string &action_type,
const std::shared_ptr<spdlog::logger> chain_logger)
: ChainAction(call_dto, action_id, action_type, chain_logger)
: ChainAction(call_dto, chain_logger)
{
}

Expand Down
6 changes: 6 additions & 0 deletions src/backends/dlib/dliblib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string>
#include "dliblib.h"
#include "imginputfileconn.h"
#include "dlibinputconns.h"
#include "outputconnectorstrategy.h"

namespace dd
Expand Down Expand Up @@ -96,6 +97,9 @@ namespace dd
}
}

// XXX Remove that to print the warnings
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
template <class TInputConnectorStrategy, class TOutputConnectorStrategy,
class TMLModel>
void DlibLib<TInputConnectorStrategy, TOutputConnectorStrategy,
Expand All @@ -121,6 +125,8 @@ namespace dd
{
// NOT IMPLEMENTED
}
// XXX Remove that to print the warnings
#pragma GCC diagnostic pop

template <class TInputConnectorStrategy, class TOutputConnectorStrategy,
class TMLModel>
Expand Down
5 changes: 3 additions & 2 deletions src/jsonapi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,10 @@ namespace dd
return dd_service_bad_request_1006();
}
if (store_config
&& JsonAPI::store_json_config_blob(tfmodel._repo, jstr))
&& JsonAPI::store_json_config_blob(dlibmodel._repo, jstr))
_logger->error("couldn't write {} file in model repository {}",
JsonAPI::_json_config_blob_fname, tfmodel._repo);
JsonAPI::_json_config_blob_fname,
dlibmodel._repo);
}
#endif
#ifdef USE_XGBOOST
Expand Down

0 comments on commit 12d181f

Please sign in to comment.