-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict.py
51 lines (40 loc) · 1.07 KB
/
predict.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
51
import os
import sys
import time
from call_methods import make_model
from options.predict_option import PredictOptions
from utils import tb_visualizer
from utils.utils import set_seed
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def run() -> None:
"""
Run the prediction process
Parameters
----------
None
Returns
-------
None
Process
-------
1. Parse the prediction options
2. Set the random seed
3. Create the model
4. Load the model weights
5. Predict the output
6. Save the output
"""
opt = PredictOptions().parse()
# Set seed
set_seed(opt.seed)
model = make_model(opt.model_name, opt)
visualizer = tb_visualizer.Visualizer(opt)
start = time.time()
model.load_trained_generator(opt.model_path)
model.predict()
visualizer.log_image(model.vis_data, total_steps=opt.label, is_train=False)
end = time.time()
visualizer.log_time(end, start, epoch=1, is_train=False, training_end=True)
visualizer.close()
if __name__ == "__main__":
run()