MCPcopy
hub / github.com/microsoft/Cream / run

Method run

CDARTS/CDARTS_segmentation/tools/engine/tester.py:48–99  ·  view source on GitHub ↗

There are four evaluation modes: 1.only eval a .pth model: -e *.pth 2.only eval a certain epoch: -e epoch 3.eval all epochs in a given section: -e start_epoch-end_epoch 4.eval all epochs from a certain started epoch: -e start_epoch-

(self, model_path, model_indice, log_file, log_file_link)

Source from the content-addressed store, hash-verified

46 self.show_prediction = show_prediction
47
48 def run(self, model_path, model_indice, log_file, log_file_link):
49 """There are four evaluation modes:
50 1.only eval a .pth model: -e *.pth
51 2.only eval a certain epoch: -e epoch
52 3.eval all epochs in a given section: -e start_epoch-end_epoch
53 4.eval all epochs from a certain started epoch: -e start_epoch-
54 """
55 if '.pth' in model_indice:
56 models = [model_indice, ]
57 elif "-" in model_indice:
58 start_epoch = int(model_indice.split("-")[0])
59 end_epoch = model_indice.split("-")[1]
60
61 models = os.listdir(model_path)
62 models.remove("epoch-last.pth")
63 sorted_models = [None] * len(models)
64 model_idx = [0] * len(models)
65
66 for idx, m in enumerate(models):
67 num = m.split(".")[0].split("-")[1]
68 model_idx[idx] = num
69 sorted_models[idx] = m
70 model_idx = np.array([int(i) for i in model_idx])
71
72 down_bound = model_idx >= start_epoch
73 up_bound = [True] * len(sorted_models)
74 if end_epoch:
75 end_epoch = int(end_epoch)
76 assert start_epoch < end_epoch
77 up_bound = model_idx <= end_epoch
78 bound = up_bound * down_bound
79 model_slice = np.array(sorted_models)[bound]
80 models = [os.path.join(model_path, model) for model in
81 model_slice]
82 else:
83 models = [os.path.join(model_path,
84 'epoch-%s.pth' % model_indice), ]
85
86 results = open(log_file, 'a')
87 link_file(log_file, log_file_link)
88
89 for model in models:
90 logger.info("Load Model: %s" % model)
91 self.val_func = load_model(self.network, model)
92 result_line, mIoU = self.multi_process_evaluation()
93
94 results.write('Model: ' + model + '\n')
95 results.write(result_line)
96 results.write('\n')
97 results.flush()
98
99 results.close()
100
101 def run_online(self):
102 """

Callers

nothing calls this directly

Calls 4

link_fileFunction · 0.90
load_modelFunction · 0.90
writeMethod · 0.45

Tested by

no test coverage detected