INT8 量化后的分类网络,不同图片,分类结果一样
SophieChang66 opened this issue · 0 comments
SophieChang66 commented
你好,我使用你的工具生成了一个.table,并使用最新的NCNN将模型转了*int8.param, *int8.bin,使用如下方式调用: yawn_quan_net->opt.use_int8_inference = true;
yawn_quan_net->load_param(yawn_quan_param_file.c_str());
if(yawn_quan_net->load_model(yawn_quan_model_file.c_str()) != 0){
LOG(INFO) << "fail to load yawn model";
return -1;
}
cv::String image_path = "/home..../*.jpg";
std::vector<cv::String> image_list;
cv::glob(image_path, image_list);
for(const auto image_file : image_list){
cv::Mat src = cv::imread(image_file, CV_LOAD_IMAGE_GRAYSCALE);
cv::Mat scale_img;
cv::resize(src, scale_img, cv::Size(32, 32));
cv::Rect r(cv::Point(2, 2), cv::Point(30, 30));
cv::Mat input_img = scale_img(r).clone();
ncnn::Mat in = ncnn::Mat::from_pixels(input_img.data, ncnn::Mat::PIXEL_GRAY, input_img.cols, input_img.rows);
const float norm = 0.00390625;
const float mean = 0.0;
in.substract_mean_normalize(&mean, &norm);
ncnn::Extractor ex = yawn_quan_net->create_extractor();
ex.set_light_mode(true);
ex.set_num_threads(2);
ncnn::Mat out;
ex.input("data", in);
ex.extract("prob", out);
float* yawn_prob = (float *)out.data;
float yawn_prob_yes = *(yawn_prob + 1);
}
然而每个yawn_prob = 0.999462,请问是哪里有问题,会是.tabel文件的原因吗?