56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
import io
|
|
import subprocess
|
|
|
|
|
|
def call_subprocess(cmd):
|
|
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
|
error = False
|
|
for process_line_output in io.TextIOWrapper(process.stdout,
|
|
encoding="utf-8"): # print output of training process to console
|
|
if 'Traceback' in process_line_output:
|
|
error = True
|
|
print(process_line_output)
|
|
if error:
|
|
raise RuntimeError("An error occured during calling subprocess")
|
|
|
|
|
|
def get_values_from_conff_matrix(path):
|
|
lines = open(path, 'r').readlines()[:7]
|
|
d = {}
|
|
for l in lines:
|
|
key, value, *_ = l.split("\t")
|
|
d.update({key.replace(":", ""): int(value)})
|
|
return d
|
|
|
|
|
|
def get_bayes_params_as_dict(x):
|
|
return {
|
|
'epochs': int(x[:, 0]),
|
|
'batch-size': int(x[:, 1]),
|
|
'multi-scale': bool(x[:, 2]),
|
|
'img-size': f"{int(x[:, 3])} {int(x[:, 4])}",
|
|
'rect': bool(x[:, 5]),
|
|
'adam': bool(x[:, 6]),
|
|
'giou': float(x[:, 7]), # train hyps start index
|
|
'cls': float(x[:, 8]),
|
|
'cls_pw': float(x[:, 9]),
|
|
'obj': float(x[:, 10]),
|
|
'obj_pw': float(x[:, 11]),
|
|
'iou_t': float(x[:, 12]),
|
|
'lr0': float(x[:, 13]),
|
|
'lrf': float(x[:, 14]),
|
|
'momentum': float(x[:, 15]),
|
|
'weight_decay': float(x[:, 16]),
|
|
'fl_gamma': float(x[:, 17]),
|
|
'hsv_h': float(x[:, 18]),
|
|
'hsv_s': float(x[:, 19]),
|
|
'hsv_v': float(x[:, 20]),
|
|
'degrees': float(x[:, 21]),
|
|
'translate': float(x[:, 22]),
|
|
'scale': float(x[:, 23]),
|
|
'shear': float(x[:, 24]), # train hyps end index
|
|
'test-img-size': int(x[:, 25]),
|
|
'conf-thres': float(x[:, 26]),
|
|
'iou-thres': float(x[:, 27])
|
|
}
|