mirror of
				https://github.com/PaddlePaddle/FastDeploy.git
				synced 2025-10-31 20:02:53 +08:00 
			
		
		
		
	add csrc code
This commit is contained in:
		
							
								
								
									
										51
									
								
								csrc/fastdeploy/text/text_model.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								csrc/fastdeploy/text/text_model.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| // 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 <memory> | ||||
|  | ||||
| #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<std::string>& raw_text_array, | ||||
|                             Result* result, const PredictionOption& option); | ||||
|   template <typename T, typename... Args> | ||||
|   void SetPreprocessor(Args&&... args) { | ||||
|     preprocessor_ = utils::make_unique<T>(std::forward<Args>(args)...); | ||||
|   } | ||||
|   template <typename T, typename... Args> | ||||
|   void SetPostprocessor(Args&&... args) { | ||||
|     postprocessor_ = utils::make_unique<T>(std::forward<Args>(args)...); | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   std::unique_ptr<Preprocessor> preprocessor_; | ||||
|   std::unique_ptr<Postprocessor> postprocessor_; | ||||
| }; | ||||
|  | ||||
| }  // namespace text | ||||
| }  // namespace fastdeploy | ||||
		Reference in New Issue
	
	Block a user
	 jiangjiajun
					jiangjiajun