-
Notifications
You must be signed in to change notification settings - Fork 4
/
prediction.py
executable file
·51 lines (37 loc) · 1.35 KB
/
prediction.py
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
49
50
#!/usr/bin/env python3
"""
Inference using provided pre-trained model
Editor: Marshall Xu
Last edited: 18/10/2023
"""
import os
import config.pred_config as pred_config
from utils import preprocess_procedure, make_prediction
args = pred_config.pred_parser.parse_args()
ds_path = args.ds_path # path to original data
ps_path = args.ps_path # path to preprocessed data
out_path = args.out_path # path to infered data
if os.path.exists(out_path) == False:
print(f"{out_path} does not exist.")
os.mkdir(out_path)
print(f"{out_path} has been created!")
prep_mode = args.prep_mode # preprocessing mode
# when the preprocess is skipped,
# directly take the raw data for inference
if prep_mode == 4:
ps_path = ds_path
model_type = args.mo # model type
in_chan = args.ic # input channel
ou_chan = args.oc # output channel
fil_num = args.fil # number of filters
threshold_vector = [args.thresh, args.cc]
pretrained_model = args.pretrained # path to pretrained model
if __name__ == "__main__":
print("Prediction session will start shortly..")
# preprocess procedure
preprocess_procedure(ds_path, ps_path, prep_mode)
# make prediction
make_prediction(model_type, in_chan, ou_chan,
fil_num, ps_path, out_path,
threshold_vector[0], threshold_vector[1], pretrained_model,
mip_flag=True)