Update
This commit is contained in:
parent
43a5d4568a
commit
6394fd3e09
|
@ -1,6 +1,6 @@
|
|||
classes=21
|
||||
train=./data/widok_01_21/widok_01_21_train_labels.txt
|
||||
valid=./data/widok_01_21/widok_01_21_test_labels.txt
|
||||
names=./data/widok_01_21/widok_01_21.names
|
||||
train=/data/widok_01_21/widok_01_21_train_labels.txt
|
||||
valid=/data/widok_01_21/widok_01_21_test_labels.txt
|
||||
names=/data/widok_01_21/widok_01_21.names
|
||||
backup=backup/
|
||||
eval=coco
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -43,7 +43,7 @@ train:
|
|||
experiments:
|
||||
dir: ./experiments
|
||||
detect:
|
||||
source: /home/tomekb/yolov3/data/widok_01_19/widok_01_19_test_labels.txt
|
||||
source: ./data/widok_01_19/widok_01_19_test_labels.txt
|
||||
test-img-size: 1024
|
||||
conf-thres: 0.3
|
||||
iou-thres: 0.6
|
||||
|
@ -51,7 +51,7 @@ detect:
|
|||
agnostic-nms:
|
||||
augment:
|
||||
confussion-matrix:
|
||||
labels-dir: /home/tomekb/yolov3/data/widok_01_19/widok_01_19_labels
|
||||
labels-dir: ./data/widok_01_19/widok_01_19_labels
|
||||
bayes:
|
||||
todo: todo
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Configuration:
|
|||
for key, value in config_file['bayes'].items():
|
||||
self.__dict__[key] = value
|
||||
|
||||
def __init__(self, config_path='./config_bayes.yml') -> None:
|
||||
def __init__(self, config_path) -> None:
|
||||
self.config_path = config_path
|
||||
file = yaml.load(open(config_path, 'r'), Loader=yaml.Loader)
|
||||
self.train = self.Train(file)
|
||||
|
|
|
@ -18,12 +18,12 @@ train:
|
|||
img-size-start:
|
||||
type: discrete
|
||||
min: 512
|
||||
max: 1088
|
||||
max: 576
|
||||
step: 64
|
||||
img-size-end:
|
||||
type: discrete
|
||||
min: 512
|
||||
max: 1088
|
||||
max: 576
|
||||
step: 64
|
||||
rect:
|
||||
type: discrete
|
||||
|
@ -122,7 +122,7 @@ detect:
|
|||
test-img-size:
|
||||
type: discrete
|
||||
min: 512
|
||||
max: 1088
|
||||
max: 576
|
||||
step: 64
|
||||
conf-thres:
|
||||
type: continuous
|
||||
|
|
|
@ -6,19 +6,22 @@ import shutil
|
|||
import traceback
|
||||
|
||||
import GPyOpt
|
||||
import numpy as np
|
||||
|
||||
from config_bayes import Configuration
|
||||
|
||||
from utils import call_subprocess, get_values_from_conff_matrix
|
||||
|
||||
config = Configuration()
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
PROJECT_ROOT = os.path.join(dir_path, '..')
|
||||
|
||||
bayes_config_yaml = os.path.join(dir_path, 'config_bayes.yml')
|
||||
config = Configuration(bayes_config_yaml)
|
||||
|
||||
date_string = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
|
||||
bayes_params_file = open(os.path.join(config.experiments.dir, f"{date_string}_bayes_params.txt"), 'a+')
|
||||
bayes_params_file = open(os.path.join(PROJECT_ROOT, config.experiments.dir, f"{date_string}_bayes_params.txt"), 'a+')
|
||||
|
||||
|
||||
def call_training_script(gaussian_hyps):
|
||||
cmd = 'python-u /home/tomekb/yolov3/train.py'
|
||||
cmd = 'python -u train.py'
|
||||
cmd += ' --epochs ' + gaussian_hyps['epochs'].__str__()
|
||||
cmd += ' --batch-size ' + gaussian_hyps['batch-size'].__str__()
|
||||
cmd += ' --cfg ' + config.train.cfg.__str__()
|
||||
|
@ -40,11 +43,7 @@ def call_training_script(gaussian_hyps):
|
|||
print("_______ CALLING TRAINING SCRIPT _______")
|
||||
print(cmd)
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
os.chdir(os.path.join(dir_path, '..')) # change to project root directory
|
||||
|
||||
call_subprocess(cmd)
|
||||
|
||||
return cmd
|
||||
|
||||
|
||||
|
@ -58,7 +57,7 @@ def move_training_results_to_experiments_dir():
|
|||
os.mkdir(training_results_dir_path)
|
||||
|
||||
weights_path = os.path.join(training_results_dir_path, 'best.pt')
|
||||
shutil.move('/home/tomekb/yolov3/weights/best.pt', weights_path) # move best weights
|
||||
shutil.move('./weights/best.pt', weights_path) # move best weights
|
||||
|
||||
names_path = open(config.train.data).readlines()[3].split('=')[-1].rstrip() # read names path from file
|
||||
names_file_name = ntpath.basename(names_path)
|
||||
|
@ -66,7 +65,7 @@ def move_training_results_to_experiments_dir():
|
|||
shutil.copy(names_path,
|
||||
experiment_names_path) # copy names file from *.data file to created experiment dir with training results
|
||||
|
||||
tensorboard_dir = '/home/tomekb/yolov3/runs'
|
||||
tensorboard_dir = './runs'
|
||||
tensorboard_events_files = glob.glob(os.path.join(tensorboard_dir, '*'))
|
||||
last_modified_events_file = max(tensorboard_events_files, key=os.path.getmtime)
|
||||
shutil.move(last_modified_events_file,
|
||||
|
@ -74,17 +73,12 @@ def move_training_results_to_experiments_dir():
|
|||
|
||||
shutil.copy2(config.config_path, training_results_dir_path) # copying configuration yaml
|
||||
|
||||
# for test purposes only
|
||||
# TODO CHANGE ME AFTER TESTS
|
||||
shutil.copy2('/home/tomekb/yolov3/experiments/yolov3-spp-100-epochs-freeze-layers/best.pt',
|
||||
training_results_dir_path)
|
||||
|
||||
return weights_path, experiment_names_path, training_results_dir_path
|
||||
|
||||
|
||||
def call_detection_script(gaussian_hyps, weights_path, names_path, dir):
|
||||
detect_output_dir = os.path.join(dir, 'output')
|
||||
cmd = f"""/home/tomekb/miniconda3/envs/conda3.7/bin/python -u /home/tomekb/yolov3/detect.py
|
||||
cmd = f"""python -u ./detect.py
|
||||
--cfg {config.train.cfg}
|
||||
--source {config.detect.source}
|
||||
--output {detect_output_dir}
|
||||
|
@ -107,7 +101,7 @@ def call_detection_script(gaussian_hyps, weights_path, names_path, dir):
|
|||
def call_generate_confussion_matrix(detect_output_dir, names_path, train_results_dir):
|
||||
labels_dir = getattr(config.confussion_matrix, 'labels-dir')
|
||||
conff_matrix_path = os.path.join(train_results_dir, 'confussion-matrix.tsv')
|
||||
cmd = f"node /home/tomekb/yolov3/our_scripts/generate-confusion-matrix.js {detect_output_dir} {labels_dir} {names_path} > {conff_matrix_path}"
|
||||
cmd = f"node ./our_scripts/generate-confusion-matrix.js {detect_output_dir} {labels_dir} {names_path} > {conff_matrix_path}"
|
||||
print("_______ CALLING CONFUSSION MATRIX SCRIPT _______")
|
||||
print(cmd)
|
||||
call_subprocess(cmd)
|
||||
|
@ -171,10 +165,7 @@ def yolov3(x):
|
|||
bayes_params_file.writelines([line, '\n'])
|
||||
|
||||
|
||||
|
||||
# uruchamiać z
|
||||
if __name__ == '__main__':
|
||||
|
||||
bounds = config.get_bayes_bounds()
|
||||
|
||||
# for b in bounds:
|
||||
|
@ -184,6 +175,8 @@ if __name__ == '__main__':
|
|||
X = None
|
||||
Y = None
|
||||
|
||||
os.chdir(PROJECT_ROOT) # change to project root directory
|
||||
|
||||
bayes_optimizer = GPyOpt.methods.BayesianOptimization(f=yolov3, domain=bounds, X=X, Y=Y, verbosity=True,
|
||||
initial_design_numdata=2)
|
||||
bayes_optimizer.run_optimization(config.bayes.iterations, verbosity=True)
|
||||
|
|
Loading…
Reference in New Issue