mirror of
				https://github.com/PaddlePaddle/FastDeploy.git
				synced 2025-10-31 11:56:44 +08:00 
			
		
		
		
	Add detection and segmentation examples for Ascend deployment
This commit is contained in:
		| @@ -131,6 +131,33 @@ void TrtInfer(const std::string& model_dir, const std::string& image_file) { | ||||
|   std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl; | ||||
| } | ||||
|  | ||||
| void AscendInfer(const std::string& model_dir, const std::string& image_file) { | ||||
|   auto model_file = model_dir + sep + "model.pdmodel"; | ||||
|   auto params_file = model_dir + sep + "model.pdiparams"; | ||||
|   auto config_file = model_dir + sep + "infer_cfg.yml"; | ||||
|   auto option = fastdeploy::RuntimeOption(); | ||||
|   option.UseAscend(); | ||||
|   auto model = fastdeploy::vision::detection::PPYOLOE(model_file, params_file, | ||||
|                                                       config_file, option); | ||||
|   if (!model.Initialized()) { | ||||
|     std::cerr << "Failed to initialize." << std::endl; | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   auto im = cv::imread(image_file); | ||||
|  | ||||
|   fastdeploy::vision::DetectionResult res; | ||||
|   if (!model.Predict(im, &res)) { | ||||
|     std::cerr << "Failed to predict." << std::endl; | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   std::cout << res.Str() << std::endl; | ||||
|   auto vis_im = fastdeploy::vision::VisDetection(im, res, 0.5); | ||||
|   cv::imwrite("vis_result.jpg", vis_im); | ||||
|   std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl; | ||||
| } | ||||
|  | ||||
| int main(int argc, char* argv[]) { | ||||
|   if (argc < 4) { | ||||
|     std::cout | ||||
| @@ -151,6 +178,8 @@ int main(int argc, char* argv[]) { | ||||
|     TrtInfer(argv[1], argv[2]); | ||||
|   } else if (std::atoi(argv[3]) == 3) { | ||||
|     KunlunXinInfer(argv[1], argv[2]); | ||||
|   } else if (std::atoi(argv[3]) == 4) { | ||||
|     AscendInfer(argv[1], argv[2]); | ||||
|   } | ||||
|   return 0; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 yunyaoXYY
					yunyaoXYY