-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
48 lines (27 loc) · 1.01 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
#include<vector>
#include<torch/script.h>
#include<opencv2/opencv.hpp>
#include<time.h>
#include<map>
#include "brainUnet.hpp"
using std::cout;
using std::endl;
int main() {
std::string module_path = "/home/mustafa/Desktop/pytorch_cpp/Unet_CPP/model/cuda_unet_brain.pt";
std::string img_path = "/home/mustafa/Desktop/pytorch_cpp/Unet_CPP/data/TCGA_FG_6689_20020326_29.tif";
cv::Mat target_mask = cv::imread("/home/mustafa/Desktop/pytorch_cpp/Unet_CPP/data/TCGA_FG_6689_20020326_29_mask.tif");
if(target_mask.empty()){
cout << "Unable to read frame" << endl;
return 0;
}
BrainUnetModel& UnetBrain = BrainUnetModel::getInstance();
UnetBrain.setDataPath(img_path);
UnetBrain.setModelPath(module_path);
cv::Mat output_mask = UnetBrain.forwardModel();
cv::imshow("target_mask", target_mask);
cv::imshow("predicted_mask", output_mask);
cv::imwrite("../predicted_mask.tif", output_mask);
cv::waitKey(0);
return 0;
}