Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
yq committed Nov 30, 2018
1 parent a367577 commit 248909f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/evaluator/test_realdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ int main(int argc, char ** argv) {
exit(-1);
}

cv::resize(img, img, cp_net_imgsize);
Tensor img_tensor = torch::from_blob(img.data, {img.rows, img.cols, 3}, kByte);
// cv::resize(img, img, cp_net_imgsize);
cv::Mat canvas = cv::Mat::zeros(cp_net_imgsize, CV_8UC3);
cv::Rect roi_rect( cp_net_imgsize.width / 2 - img.cols / 2,
cp_net_imgsize.height / 2 - img.rows / 2,
img.cols,
img.rows);
img.copyTo(canvas(roi_rect));

Tensor img_tensor = torch::from_blob(canvas.data, {canvas.rows, canvas.cols, 3}, kByte);
img_tensor = img_tensor.permute({2, 0, 1}).toType(kFloat32).div_(255).unsqueeze(0);
img_tensor = img_tensor.to(device);

Expand All @@ -72,7 +79,7 @@ int main(int argc, char ** argv) {
cout << output << endl;
cout << "pred " << class_idx << " " << symbols[class_idx] << endl;

cv::imshow("img", img);
cv::imshow("canvas", canvas);
cv::waitKey();

}
Expand Down

0 comments on commit 248909f

Please sign in to comment.