-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dto): example service_create+ncnn
The Service Create call works, but most parameters doesn't. Supported parameters are only those declared in the DTO files. To not update all input/output connector code. This PR just convert the DTO into APIData to pass it to connector. /!\ But beware if a parameters is not present in the DTO it will be ignored and will not be present in the generated APIData passed to the connectors. /!\ That's why we need first to fill the InputConnector and OutputConnector with all possible option from all type and all backends. cmake .. -D USE_HTTP_SERVER_OATPP=ON -D USE_HTTP_SERVER=OFF -D USE_NCNN=ON -D USE_CAFFE=OFF -DUSE_COMMAND_LINE=OFF
- Loading branch information
Showing
19 changed files
with
419 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* DeepDetect | ||
* Copyright (c) 2021 Jolibrain SASU | ||
* Author: Mehdi Abaakouk <[email protected]> | ||
* | ||
* This file is part of deepdetect. | ||
* | ||
* deepdetect is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* deepdetect is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with deepdetect. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DTO_MLLIB_H | ||
#define DTO_MLLIB_H | ||
|
||
#include "dd_config.h" | ||
#include "utils/utils.hpp" | ||
#include "oatpp/core/Types.hpp" | ||
#include "oatpp/core/macro/codegen.hpp" | ||
|
||
namespace dd | ||
{ | ||
namespace DTO | ||
{ | ||
#include OATPP_CODEGEN_BEGIN(DTO) ///< Begin DTO codegen section | ||
|
||
class MLLib : public oatpp::DTO | ||
{ | ||
DTO_INIT(MLLib, DTO /* extends */) | ||
|
||
// NCNN Options | ||
DTO_FIELD_INFO(nclasses) | ||
{ | ||
info->description = "number of output classes (`supervised` service " | ||
"type), classification only"; | ||
}; | ||
DTO_FIELD(Int32, nclasses) = 0; | ||
|
||
DTO_FIELD_INFO(threads) | ||
{ | ||
info->description = "number of threads"; | ||
}; | ||
DTO_FIELD(Int32, threads) = dd::dd_utils::my_hardware_concurrency(); | ||
|
||
DTO_FIELD_INFO(lightmode) | ||
{ | ||
info->description = "enable light mode"; | ||
}; | ||
DTO_FIELD(Boolean, lightmode) = true; | ||
|
||
DTO_FIELD_INFO(inputBlob) | ||
{ | ||
info->description = "network input blob name"; | ||
}; | ||
DTO_FIELD(String, inputBlob) = "data"; | ||
|
||
DTO_FIELD_INFO(outputBlob) | ||
{ | ||
info->description = "network output blob name (default depends on " | ||
"network type(ie prob or " | ||
"rnn_pred or probs or detection_out)"; | ||
}; | ||
DTO_FIELD(String, outputBlob); | ||
|
||
DTO_FIELD_INFO(datatype) | ||
{ | ||
info->description = "fp16 or fp32"; | ||
}; | ||
|
||
DTO_FIELD(String, datatype) = "fp16"; | ||
}; | ||
#include OATPP_CODEGEN_END(DTO) ///< End DTO codegen section | ||
|
||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* DeepDetect | ||
* Copyright (c) 2021 Jolibrain SASU | ||
* Author: Mehdi Abaakouk <[email protected]> | ||
* | ||
* This file is part of deepdetect. | ||
* | ||
* deepdetect is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* deepdetect is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with deepdetect. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DTO_MODEL | ||
#define DTO_MODEL | ||
|
||
#include "oatpp/core/Types.hpp" | ||
#include "oatpp/core/macro/codegen.hpp" | ||
|
||
namespace dd | ||
{ | ||
namespace DTO | ||
{ | ||
#include OATPP_CODEGEN_BEGIN(DTO) ///< Begin DTO codegen section | ||
|
||
|
||
class Model: public oatpp::DTO | ||
{ | ||
DTO_INIT(Model, DTO /* extends */) | ||
DTO_FIELD(String, repository); | ||
DTO_FIELD(String, init); | ||
DTO_FIELD(Boolean, create_repository) = false; | ||
DTO_FIELD(Boolean, index_preload) = false; | ||
}; | ||
|
||
#include OATPP_CODEGEN_END(DTO) ///< End DTO codegen section | ||
|
||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* DeepDetect | ||
* Copyright (c) 2021 Jolibrain SASU | ||
* Author: Mehdi Abaakouk <[email protected]> | ||
* | ||
* This file is part of deepdetect. | ||
* | ||
* deepdetect is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* deepdetect is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with deepdetect. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DTO_PARAMETERS_H | ||
#define DTO_PARAMETERS_H | ||
|
||
#include "oatpp/core/Types.hpp" | ||
#include "oatpp/core/macro/codegen.hpp" | ||
#include "dto/mllib.hpp" | ||
#include "dto/input_connector.hpp" | ||
#include "dto/output_connector.hpp" | ||
|
||
namespace dd | ||
{ | ||
namespace DTO | ||
{ | ||
#include OATPP_CODEGEN_BEGIN(DTO) ///< Begin DTO codegen section | ||
|
||
class Parameters: public oatpp::DTO | ||
{ | ||
DTO_INIT(Parameters, DTO /* extends */) | ||
DTO_FIELD(Object<InputConnector>, input) = InputConnector::createShared(); | ||
DTO_FIELD(Object<MLLib>, mllib) = MLLib::createShared(); | ||
DTO_FIELD(Object<OutputConnector>, output) = OutputConnector::createShared(); | ||
}; | ||
|
||
#include OATPP_CODEGEN_END(DTO) ///< End DTO codegen section | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* DeepDetect | ||
* Copyright (c) 2021 Jolibrain SASU | ||
* Author: Mehdi Abaakouk <[email protected]> | ||
* | ||
* This file is part of deepdetect. | ||
* | ||
* deepdetect is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* deepdetect is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with deepdetect. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DTO_SERVICE_CREATE_H | ||
#define DTO_SERVICE_CREATE_H | ||
|
||
#include "oatpp/core/Types.hpp" | ||
#include "oatpp/core/macro/codegen.hpp" | ||
#include "dto/model.hpp" | ||
#include "dto/parameters.hpp" | ||
|
||
namespace dd | ||
{ | ||
namespace DTO | ||
{ | ||
#include OATPP_CODEGEN_BEGIN(DTO) ///< Begin DTO codegen section | ||
|
||
class ServiceCreate : public oatpp::DTO | ||
{ | ||
DTO_INIT(ServiceCreate, DTO /* extends */) | ||
|
||
DTO_FIELD(String, mllib); | ||
DTO_FIELD(String, description) = ""; | ||
DTO_FIELD(String, type) = "supervised"; | ||
DTO_FIELD(Object<Parameters>, parameters) = Parameters::createShared(); | ||
DTO_FIELD(Object<Model>, model) = Model::createShared(); | ||
}; | ||
|
||
#include OATPP_CODEGEN_END(DTO) ///< End DTO codegen section | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.