Skip to content

Commit 19f7338

Browse files
committed
v0.7.1b fix bug of fp32 model.
1 parent 834ccd0 commit 19f7338

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

model.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,17 @@ bool SmartModel::run(const QString &image_file, QVector<box_t> &boxes) {
105105
cv::resize(img, img, {(int)round(img.cols * scale), (int)round(img.rows * scale)});
106106
cv::Mat input(640, 640, CV_8UC3, 127);
107107
img.copyTo(input({0, 0, img.cols, img.rows}));
108-
auto x = cv::dnn::blobFromImage(input);
108+
109+
// TODO: 为了兼容int8模型和fp32模型的不同输入格式而加的临时操作
110+
// 后续会统一两个模型的输入格式
111+
cv::Mat x;
112+
if(mode == "openvino-int8-cpu") {
113+
x = cv::dnn::blobFromImage(input);
114+
} else {
115+
cv::cvtColor(input, input, cv::COLOR_BGR2RGB);
116+
x = cv::dnn::blobFromImage(input) / 255;
117+
}
118+
109119
net.setInput(x);
110120
auto y = net.forward();
111121
QVector<box_t> before_nms;

0 commit comments

Comments
 (0)