From 761af574710974eed7c66ded6abe9877b8e0de80 Mon Sep 17 00:00:00 2001 From: liuruilong Date: Fri, 6 Jul 2018 17:28:15 +0800 Subject: [PATCH] update ios io --- src/ios_io/PaddleMobile.h | 5 +++++ src/ios_io/PaddleMobile.mm | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/ios_io/PaddleMobile.h b/src/ios_io/PaddleMobile.h index 091a892ab9..1844bbf037 100644 --- a/src/ios_io/PaddleMobile.h +++ b/src/ios_io/PaddleMobile.h @@ -29,6 +29,11 @@ */ - (BOOL)load:(NSString *)modelPath andWeightsPath:(NSString *)weighsPath; +/* + 加载散开形式的模型, 需传入模型的目录 +*/ +- (BOOL)load:(NSString *)modelAndWeightPath; + /* 进行预测, means 和 scale 为训练模型时的预处理参数, 如训练时没有做这些预处理则直接使用 predict */ diff --git a/src/ios_io/PaddleMobile.mm b/src/ios_io/PaddleMobile.mm index f5ec2afb2a..e3ed909394 100644 --- a/src/ios_io/PaddleMobile.mm +++ b/src/ios_io/PaddleMobile.mm @@ -62,6 +62,15 @@ static std::mutex shared_mutex; } } +- (BOOL)load:(NSString *)modelAndWeightPath{ + std::string model_path_str = std::string([modelAndWeightPath UTF8String]); + if (loaded_ = pam_->Load(model_path_str)) { + return YES; + } else { + return NO; + } +} + -(void)preprocess:(const UInt8 *)input output:(float *)output imageWidth:(int)imageWidth imageHeight:(int)imageHeight imageChannels:(int)imageChannels means:(NSArray *)means scale:(float)scale dim:(std::vector)dim{ if (means == nil) { means = @[@0, @0, @0]; -- GitLab