// 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. #pragma once #include #include "fastdeploy/fastdeploy_model.h" #include "fastdeploy/utils/unique_ptr.h" namespace fastdeploy { namespace text { class Preprocessor; class Postprocessor; class Result; class PredictionOption; class FASTDEPLOY_DECL TextModel : public FastDeployModel { public: virtual std::string ModelName() const { return "TextModel"; } virtual bool Predict(const std::string& raw_text, Result* result, const PredictionOption& option); virtual bool PredictBatch(const std::vector& raw_text_array, Result* result, const PredictionOption& option); template void SetPreprocessor(Args&&... args) { preprocessor_ = utils::make_unique(std::forward(args)...); } template void SetPostprocessor(Args&&... args) { postprocessor_ = utils::make_unique(std::forward(args)...); } private: std::unique_ptr preprocessor_; std::unique_ptr postprocessor_; }; } // namespace text } // namespace fastdeploy