提交 e7ede460 编写于 作者: S sjtubinlong

update docs

上级 ad9da388
...@@ -44,7 +44,9 @@ void LoadModel( ...@@ -44,7 +44,9 @@ void LoadModel(
std::unique_ptr<paddle::PaddlePredictor>* predictor) { std::unique_ptr<paddle::PaddlePredictor>* predictor) {
// Config the model info // Config the model info
paddle::AnalysisConfig config; paddle::AnalysisConfig config;
config.SetModel(model_dir); auto prog_file = model_dir + "/__model__";
auto params_file = model_dir + "/__params__";
config.SetModel(prog_file, params_file);
if (use_gpu) { if (use_gpu) {
config.EnableUseGpu(100, 0); config.EnableUseGpu(100, 0);
} else { } else {
...@@ -60,7 +62,8 @@ void LoadModel( ...@@ -60,7 +62,8 @@ void LoadModel(
void HumanSeg::Preprocess(const cv::Mat& image_mat) { void HumanSeg::Preprocess(const cv::Mat& image_mat) {
// Clone the image : keep the original mat for postprocess // Clone the image : keep the original mat for postprocess
cv::Mat im = image_mat.clone(); cv::Mat im = image_mat.clone();
cv::resize(im, im, cv::Size(192, 192), 0.f, 0.f, cv::INTER_LINEAR); auto eval_wh = cv::Size(eval_size_[0], eval_size_[1]);
cv::resize(im, im, eval_wh, 0.f, 0.f, cv::INTER_LINEAR);
im.convertTo(im, CV_32FC3, 1.0); im.convertTo(im, CV_32FC3, 1.0);
int rc = im.channels(); int rc = im.channels();
......
...@@ -37,9 +37,11 @@ class HumanSeg { ...@@ -37,9 +37,11 @@ class HumanSeg {
explicit HumanSeg(const std::string& model_dir, explicit HumanSeg(const std::string& model_dir,
const std::vector<float>& mean, const std::vector<float>& mean,
const std::vector<float>& scale, const std::vector<float>& scale,
const std::vector<int>& eval_size,
bool use_gpu = false) : bool use_gpu = false) :
mean_(mean), mean_(mean),
scale_(scale) { scale_(scale),
eval_size_(eval_size) {
LoadModel(model_dir, use_gpu, &predictor_); LoadModel(model_dir, use_gpu, &predictor_);
} }
...@@ -60,4 +62,5 @@ class HumanSeg { ...@@ -60,4 +62,5 @@ class HumanSeg {
std::vector<uchar> segout_data_; std::vector<uchar> segout_data_;
std::vector<float> mean_; std::vector<float> mean_;
std::vector<float> scale_; std::vector<float> scale_;
std::vector<int> eval_size_;
}; };
...@@ -78,7 +78,8 @@ int main(int argc, char* argv[]) { ...@@ -78,7 +78,8 @@ int main(int argc, char* argv[]) {
// Init Model // Init Model
std::vector<float> means = {104.008, 116.669, 122.675}; std::vector<float> means = {104.008, 116.669, 122.675};
std::vector<float> scale = {1.000, 1.000, 1.000}; std::vector<float> scale = {1.000, 1.000, 1.000};
HumanSeg seg(model_dir, means, scale, use_gpu); std::vector<int> eval_sz = {192, 192};
HumanSeg seg(model_dir, means, scale, eval_sz, use_gpu);
// Call ImagePredict while input_path is a image file path // Call ImagePredict while input_path is a image file path
// The output will be saved as result.jpeg // The output will be saved as result.jpeg
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册